Browse Source

Ran .net core code formatter.

pull/131/head
Steven Kirk 11 years ago
parent
commit
145411020b
  1. BIN
      Perspex.v2.ncrunchsolution
  2. 13
      Tests/Perspex.Controls.UnitTests/GridLengthTests.cs
  3. 19
      Tests/Perspex.Markup.Xaml.UnitTests/BinderTest.cs
  4. 32
      Tests/Perspex.Markup.Xaml.UnitTests/BindingDefinitionBuilder.cs
  5. 19
      Tests/Perspex.Markup.Xaml.UnitTests/ChangeBranchTest.cs
  6. 73
      Tests/Perspex.Markup.Xaml.UnitTests/DataContextChangeSynchronizerTest.cs
  7. 5
      Tests/Perspex.Markup.Xaml.UnitTests/Properties/AssemblyInfo.cs
  8. 13
      Tests/Perspex.Markup.Xaml.UnitTests/PropertyMountPointTest.cs
  9. 21
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Level1.cs
  10. 9
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Level2.cs
  11. 9
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Level3.cs
  12. 15
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/LogInViewModel.cs
  13. 29
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/MainWindowViewModel.cs
  14. 9
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/PropertyChangeNotifier.cs
  15. 11
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Repository.cs
  16. 23
      Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/UserRepositoriesViewModel.cs
  17. 3
      Tests/Perspex.Markup.Xaml.UnitTests/SamplePerspexObject.cs
  18. 35
      Tests/Perspex.Markup.Xaml.UnitTests/TypeProviderMock.cs
  19. 19
      Tests/Perspex.Markup.Xaml.UnitTests/ViewModelMock.cs
  20. 15
      Tests/Perspex.Markup.Xaml.UnitTests/XamlBindingTest.cs
  21. 13
      Tests/Perspex.SceneGraph.UnitTests/Media/BrushTests.cs
  22. 13
      Tests/Perspex.SceneGraph.UnitTests/Media/ColorTests.cs
  23. 9
      Tests/Perspex.SceneGraph.UnitTests/ThicknessTests.cs
  24. 13
      samples/TestApplication/App.cs
  25. 31
      samples/TestApplication/Program.cs
  26. 7
      samples/TestApplication/Properties/AssemblyInfo.cs
  27. 13
      samples/XamlTestApplication/App.cs
  28. 25
      samples/XamlTestApplication/MainViewModel.cs
  29. 37
      samples/XamlTestApplication/Program.cs
  30. 7
      samples/XamlTestApplication/Properties/AssemblyInfo.cs
  31. 25
      samples/XamlTestApplication/Views/MainWindow.cs
  32. 7
      src/Gtk/Perspex.Cairo/CairoExtensions.cs
  33. 29
      src/Gtk/Perspex.Cairo/CairoPlatform.cs
  34. 92
      src/Gtk/Perspex.Cairo/Media/DrawingContext.cs
  35. 35
      src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs
  36. 10
      src/Gtk/Perspex.Cairo/Media/Imaging/BitmapImpl.cs
  37. 10
      src/Gtk/Perspex.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs
  38. 44
      src/Gtk/Perspex.Cairo/Media/StreamGeometryContextImpl.cs
  39. 40
      src/Gtk/Perspex.Cairo/Media/StreamGeometryImpl.cs
  40. 9
      src/Gtk/Perspex.Cairo/Properties/AssemblyInfo.cs
  41. 36
      src/Gtk/Perspex.Cairo/Renderer.cs
  42. 19
      src/Gtk/Perspex.Gtk/AssetLoader.cs
  43. 20
      src/Gtk/Perspex.Gtk/ClipboardImpl.cs
  44. 36
      src/Gtk/Perspex.Gtk/CursorFactory.cs
  45. 7
      src/Gtk/Perspex.Gtk/GtkExtensions.cs
  46. 28
      src/Gtk/Perspex.Gtk/GtkPlatform.cs
  47. 33
      src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs
  48. 19
      src/Gtk/Perspex.Gtk/Input/GtkMouseDevice.cs
  49. 18
      src/Gtk/Perspex.Gtk/PopupImpl.cs
  50. 7
      src/Gtk/Perspex.Gtk/Properties/AssemblyInfo.cs
  51. 61
      src/Gtk/Perspex.Gtk/WindowImpl.cs
  52. 27
      src/Markup/Perspex.Markup.Xaml/Context/PerspexObjectAssembler.cs
  53. 27
      src/Markup/Perspex.Markup.Xaml/Context/PerspexParserFactory.cs
  54. 27
      src/Markup/Perspex.Markup.Xaml/Context/PerspexTypeRepository.cs
  55. 47
      src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs
  56. 19
      src/Markup/Perspex.Markup.Xaml/Context/PerspexXamlMember.cs
  57. 37
      src/Markup/Perspex.Markup.Xaml/Context/PerspexXamlMemberValuePlugin.cs
  58. 23
      src/Markup/Perspex.Markup.Xaml/Context/PerspexXamlType.cs
  59. 15
      src/Markup/Perspex.Markup.Xaml/Converters/BitmapConverter.cs
  60. 15
      src/Markup/Perspex.Markup.Xaml/Converters/BrushConverter.cs
  61. 15
      src/Markup/Perspex.Markup.Xaml/Converters/ColumnDefinitionsTypeConverter.cs
  62. 15
      src/Markup/Perspex.Markup.Xaml/Converters/GridLengthTypeConverter.cs
  63. 15
      src/Markup/Perspex.Markup.Xaml/Converters/RowDefinitionsTypeConverter.cs
  64. 13
      src/Markup/Perspex.Markup.Xaml/Converters/ThicknessConverter.cs
  65. 47
      src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/ObservablePropertyBranch.cs
  66. 23
      src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/PropertyMountPoint.cs
  67. 19
      src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/PropertyPath.cs
  68. 29
      src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/TargettedProperty.cs
  69. 87
      src/Markup/Perspex.Markup.Xaml/DataBinding/DataContextChangeSynchronizer.cs
  70. 9
      src/Markup/Perspex.Markup.Xaml/DataBinding/IPerspexPropertyBinder.cs
  71. 31
      src/Markup/Perspex.Markup.Xaml/DataBinding/PerspexPropertyBinder.cs
  72. 11
      src/Markup/Perspex.Markup.Xaml/DataBinding/SourceBindingEndpoint.cs
  73. 7
      src/Markup/Perspex.Markup.Xaml/DataBinding/TargetBindingEndpoint.cs
  74. 31
      src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBinding.cs
  75. 35
      src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBindingDefinition.cs
  76. 17
      src/Markup/Perspex.Markup.Xaml/MarkupExtensions/BindingExtension.cs
  77. 17
      src/Markup/Perspex.Markup.Xaml/MarkupExtensions/TypeExtension.cs
  78. 19
      src/Markup/Perspex.Markup.Xaml/PerspexXamlLoader.cs
  79. 7
      src/Markup/Perspex.Markup.Xaml/Properties/AssemblyInfo.cs
  80. 7
      src/Markup/Perspex.Markup.Xaml/Templates/Template.cs
  81. 27
      src/Markup/Perspex.Markup.Xaml/Templates/TemplateContent.cs
  82. 11
      src/Markup/Perspex.Markup.Xaml/Templates/TemplateLoader.cs
  83. 15
      src/Markup/Perspex.Markup.Xaml/Templates/XamlDataTemplate.cs
  84. 5
      src/NGenerics/Constants.cs
  85. 74
      src/NGenerics/DataStructures/Comparers/ComparisonComparer.cs
  86. 41
      src/NGenerics/DataStructures/Comparers/KeyValuePairComparer.cs
  87. 29
      src/NGenerics/DataStructures/Comparers/ReverseComparer.cs
  88. 139
      src/NGenerics/DataStructures/General/Heap.cs
  89. 3
      src/NGenerics/DataStructures/General/HeapType.cs
  90. 53
      src/NGenerics/DataStructures/General/IHeap.cs
  91. 41
      src/NGenerics/DataStructures/Queues/IQueue.cs
  92. 107
      src/NGenerics/DataStructures/Queues/PriorityQueue.cs
  93. 3
      src/NGenerics/DataStructures/Queues/PriorityQueueType.cs
  94. 62
      src/NGenerics/DataStructures/Trees/BinarySearchTreeBase.cs
  95. 252
      src/NGenerics/DataStructures/Trees/BinaryTree.cs
  96. 9
      src/NGenerics/DataStructures/Trees/ISearchTree.cs
  97. 13
      src/NGenerics/DataStructures/Trees/ITree.cs
  98. 3
      src/NGenerics/DataStructures/Trees/NodeColor.cs
  99. 120
      src/NGenerics/DataStructures/Trees/RedBlackTree.cs
  100. 436
      src/NGenerics/DataStructures/Trees/RedBlackTreeDictionary.cs

BIN
Perspex.v2.ncrunchsolution

Binary file not shown.

13
Tests/Perspex.Controls.UnitTests/GridLengthTests.cs

@ -1,15 +1,12 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Linq;
using Xunit;
namespace Perspex.Controls.UnitTests
{
using System;
using System.Linq;
using Xunit;
public class GridLengthTests
{
[Fact]

19
Tests/Perspex.Markup.Xaml.UnitTests/BinderTest.cs

@ -1,14 +1,17 @@
namespace Perspex.Xaml.Base.UnitTest
{
using System;
using Moq;
using Markup.Xaml.DataBinding;
using OmniXaml.TypeConversion;
using Xunit;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Moq;
using Perspex.Markup.Xaml.DataBinding;
using OmniXaml.TypeConversion;
using Xunit;
namespace Perspex.Xaml.Base.UnitTest
{
public class BinderTest
{
[Fact]
[Fact]
public void NullTarget_Throws()
{
var typeConverter = new Mock<ITypeConverterProvider>();

32
Tests/Perspex.Markup.Xaml.UnitTests/BindingDefinitionBuilder.cs

@ -1,37 +1,39 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Controls;
using Perspex.Markup.Xaml.DataBinding;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Xaml.Base.UnitTest
{
using Controls;
using Markup.Xaml.DataBinding;
using Markup.Xaml.DataBinding.ChangeTracking;
public class BindingDefinitionBuilder
{
private readonly BindingMode bindingMode;
private readonly PropertyPath sourcePropertyPath;
private Control target;
private PerspexProperty targetProperty;
private readonly BindingMode _bindingMode;
private readonly PropertyPath _sourcePropertyPath;
private Control _target;
private PerspexProperty _targetProperty;
public BindingDefinitionBuilder()
{
bindingMode = BindingMode.Default;
sourcePropertyPath = new PropertyPath(string.Empty);
_bindingMode = BindingMode.Default;
_sourcePropertyPath = new PropertyPath(string.Empty);
}
public BindingDefinitionBuilder WithNullTarget()
{
target = null;
_target = null;
return this;
}
public XamlBindingDefinition Build()
{
return new XamlBindingDefinition(
bindingMode: bindingMode,
sourcePropertyPath: sourcePropertyPath,
target: target,
targetProperty: targetProperty);
bindingMode: _bindingMode,
sourcePropertyPath: _sourcePropertyPath,
target: _target,
targetProperty: _targetProperty);
}
}
}

19
Tests/Perspex.Markup.Xaml.UnitTests/ChangeBranchTest.cs

@ -1,10 +1,13 @@
namespace Perspex.Xaml.Base.UnitTest
{
using System;
using Markup.Xaml.DataBinding.ChangeTracking;
using SampleModel;
using Xunit;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
using Perspex.Xaml.Base.UnitTest.SampleModel;
using Xunit;
namespace Perspex.Xaml.Base.UnitTest
{
public class ChangeBranchTest
{
[Fact]
@ -23,11 +26,11 @@
public void OnePathOnly()
{
var level1 = new Level1();
var branch = new ObservablePropertyBranch(level1, new PropertyPath("Text"));
var newValue = "Hey now";
branch.Value = newValue;
Assert.Equal(level1.Text, newValue);
}

73
Tests/Perspex.Markup.Xaml.UnitTests/DataContextChangeSynchronizerTest.cs

@ -1,84 +1,87 @@
namespace Perspex.Xaml.Base.UnitTest
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Controls;
using GitHubClient.ViewModels;
using Perspex.Markup.Xaml.DataBinding;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
using OmniXaml.Builder;
using OmniXaml.TypeConversion;
using OmniXaml.TypeConversion.BuiltInConverters;
using Perspex.Xaml.Base.UnitTest.SampleModel;
using Xunit;
namespace Perspex.Xaml.Base.UnitTest
{
using System;
using Controls;
using GitHubClient.ViewModels;
using Markup.Xaml.DataBinding;
using Markup.Xaml.DataBinding.ChangeTracking;
using OmniXaml.Builder;
using OmniXaml.TypeConversion;
using OmniXaml.TypeConversion.BuiltInConverters;
using SampleModel;
using Xunit;
public class DataContextChangeSynchronizerTest
{
private TypeConverterProvider repo;
private SamplePerspexObject guiObject;
private ViewModelMock viewModel;
private TypeConverterProvider _repo;
private SamplePerspexObject _guiObject;
private ViewModelMock _viewModel;
public DataContextChangeSynchronizerTest()
{
repo = new TypeConverterProvider();
guiObject = new SamplePerspexObject();
viewModel = new ViewModelMock();
_repo = new TypeConverterProvider();
_guiObject = new SamplePerspexObject();
_viewModel = new ViewModelMock();
}
[Fact]
public void SameTypesFromUIToModel()
{
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), viewModel), new DataContextChangeSynchronizer.BindingTarget(guiObject, SamplePerspexObject.IntProperty), repo);
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), _viewModel), new DataContextChangeSynchronizer.BindingTarget(_guiObject, SamplePerspexObject.IntProperty), _repo);
synchronizer.StartUpdatingSourceWhenTargetChanges();
const int someValue = 4;
guiObject.Int = someValue;
_guiObject.Int = someValue;
Assert.Equal(someValue, viewModel.IntProp);
Assert.Equal(someValue, _viewModel.IntProp);
}
[Fact]
public void DifferentTypesFromUIToModel()
{
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), viewModel), new DataContextChangeSynchronizer.BindingTarget(guiObject, SamplePerspexObject.StringProperty), repo);
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), _viewModel), new DataContextChangeSynchronizer.BindingTarget(_guiObject, SamplePerspexObject.StringProperty), _repo);
synchronizer.StartUpdatingSourceWhenTargetChanges();
guiObject.String = "2";
_guiObject.String = "2";
Assert.Equal(2, viewModel.IntProp);
Assert.Equal(2, _viewModel.IntProp);
}
[Fact]
public void DifferentTypesAndNonConvertibleValueFromUIToModel()
{
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), viewModel), new DataContextChangeSynchronizer.BindingTarget(guiObject, SamplePerspexObject.StringProperty), repo);
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), _viewModel), new DataContextChangeSynchronizer.BindingTarget(_guiObject, SamplePerspexObject.StringProperty), _repo);
synchronizer.StartUpdatingSourceWhenTargetChanges();
guiObject.String = "";
_guiObject.String = "";
Assert.Equal(default(int), viewModel.IntProp);
Assert.Equal(default(int), _viewModel.IntProp);
}
[Fact]
public void DifferentTypesFromModelToUI()
{
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), viewModel), new DataContextChangeSynchronizer.BindingTarget(guiObject, SamplePerspexObject.StringProperty), repo);
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), _viewModel), new DataContextChangeSynchronizer.BindingTarget(_guiObject, SamplePerspexObject.StringProperty), _repo);
synchronizer.StartUpdatingTargetWhenSourceChanges();
viewModel.IntProp = 2;
Assert.Equal("2", guiObject.String);
_viewModel.IntProp = 2;
Assert.Equal("2", _guiObject.String);
}
[Fact]
public void SameTypesFromModelToUI()
{
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), viewModel), new DataContextChangeSynchronizer.BindingTarget(guiObject, SamplePerspexObject.IntProperty), repo);
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("IntProp"), _viewModel), new DataContextChangeSynchronizer.BindingTarget(_guiObject, SamplePerspexObject.IntProperty), _repo);
synchronizer.StartUpdatingTargetWhenSourceChanges();
viewModel.IntProp = 2;
_viewModel.IntProp = 2;
Assert.Equal(2, guiObject.Int);
Assert.Equal(2, _guiObject.Int);
}
[Fact]
@ -87,7 +90,7 @@
var mainWindowViewModel = new MainWindowViewModel();
var contentControl = new ContentControl();
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("Content"), mainWindowViewModel), new DataContextChangeSynchronizer.BindingTarget(contentControl, ContentControl.ContentProperty), repo);
var synchronizer = new DataContextChangeSynchronizer(new DataContextChangeSynchronizer.BindingSource(new PropertyPath("Content"), mainWindowViewModel), new DataContextChangeSynchronizer.BindingTarget(contentControl, ContentControl.ContentProperty), _repo);
synchronizer.StartUpdatingTargetWhenSourceChanges();

5
Tests/Perspex.Markup.Xaml.UnitTests/Properties/AssemblyInfo.cs

@ -1,3 +1,6 @@
using System.Reflection;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection;
[assembly: AssemblyTitle("Perspex.Markup.Xaml.UnitTests")]

13
Tests/Perspex.Markup.Xaml.UnitTests/PropertyMountPointTest.cs

@ -1,9 +1,12 @@
namespace Perspex.Xaml.Base.UnitTest
{
using Markup.Xaml.DataBinding.ChangeTracking;
using System;
using Xunit;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
using System;
using Xunit;
namespace Perspex.Xaml.Base.UnitTest
{
public class PropertyMountPointTest
{
[Fact]

21
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Level1.cs

@ -1,39 +1,42 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Perspex.Xaml.Base.UnitTest.SampleModel
{
public class Level1 : PropertyChangeNotifier
{
private Level2 level2 = new Level2();
private DateTime dateTime;
private string text;
private Level2 _level2 = new Level2();
private DateTime _dateTime;
private string _text;
public Level2 Level2
{
get { return level2; }
get { return _level2; }
set
{
level2 = value;
_level2 = value;
OnPropertyChanged();
}
}
public string Text
{
get { return text; }
get { return _text; }
set
{
text = value;
_text = value;
OnPropertyChanged();
}
}
public DateTime DateTime
{
get { return dateTime; }
get { return _dateTime; }
set
{
dateTime = value;
_dateTime = value;
OnPropertyChanged();
}
}

9
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Level2.cs

@ -1,15 +1,18 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Xaml.Base.UnitTest.SampleModel
{
public class Level2 : PropertyChangeNotifier
{
private Level3 level3 = new Level3();
private Level3 _level3 = new Level3();
public Level3 Level3
{
get { return level3; }
get { return _level3; }
set
{
level3 = value;
_level3 = value;
OnPropertyChanged();
}
}

9
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Level3.cs

@ -1,15 +1,18 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Xaml.Base.UnitTest.SampleModel
{
public class Level3 : PropertyChangeNotifier
{
private int property = 10;
private int _property = 10;
public int Property
{
get { return property; }
get { return _property; }
set
{
property = value;
_property = value;
OnPropertyChanged();
}
}

15
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/LogInViewModel.cs

@ -1,16 +1,13 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using ReactiveUI;
namespace Perspex.Xaml.Base.UnitTest.SampleModel
{
using ReactiveUI;
public class LogInViewModel : ReactiveObject
{
private string username;
private string _username;
public LogInViewModel()
{
@ -22,8 +19,8 @@ namespace Perspex.Xaml.Base.UnitTest.SampleModel
public string Username
{
get { return this.username; }
set { this.RaiseAndSetIfChanged(ref this.username, value); }
get { return _username; }
set { this.RaiseAndSetIfChanged(ref _username, value); }
}
public ReactiveCommand<object> OkCommand

29
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/MainWindowViewModel.cs

@ -1,20 +1,17 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Xaml.Base.UnitTest.SampleModel;
using ReactiveUI;
namespace GitHubClient.ViewModels
{
using System;
using Perspex.Xaml.Base.UnitTest.SampleModel;
using ReactiveUI;
public class MainWindowViewModel : ReactiveObject
{
private object content;
private object _content;
private LogInViewModel login;
private LogInViewModel _login;
public MainWindowViewModel()
{
@ -23,21 +20,21 @@ namespace GitHubClient.ViewModels
public object Content
{
get { return this.content; }
set { this.RaiseAndSetIfChanged(ref this.content, value); }
get { return _content; }
set { this.RaiseAndSetIfChanged(ref _content, value); }
}
private void ShowLogin()
{
this.login = new LogInViewModel();
this.login.OkCommand.Subscribe(_ => this.ShowRepositories());
this.Content = this.login;
_login = new LogInViewModel();
_login.OkCommand.Subscribe(_ => this.ShowRepositories());
this.Content = _login;
}
private void ShowRepositories()
{
var vm = new UserRepositoriesViewModel();
var task = vm.Load(this.login.Username);
var task = vm.Load(_login.Username);
this.Content = vm;
}
}

9
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/PropertyChangeNotifier.cs

@ -1,8 +1,11 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Perspex.Xaml.Base.UnitTest.SampleModel
{
using System.ComponentModel;
using System.Runtime.CompilerServices;
public abstract class PropertyChangeNotifier : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

11
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/Repository.cs

@ -1,17 +1,20 @@
namespace GitHubClient.ViewModels
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace GitHubClient.ViewModels
{
public class Repository
{
private readonly string name;
private readonly string _name;
public Repository(string name)
{
this.name = name;
_name = name;
}
public string Name
{
get { return name; }
get { return _name; }
}
}
}

23
Tests/Perspex.Markup.Xaml.UnitTests/SampleModel/UserRepositoriesViewModel.cs

@ -1,29 +1,26 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using System.Threading.Tasks;
using GitHubClient.ViewModels;
using ReactiveUI;
namespace Perspex.Xaml.Base.UnitTest.SampleModel
{
using System.Collections.Generic;
using System.Threading.Tasks;
using GitHubClient.ViewModels;
using ReactiveUI;
public class UserRepositoriesViewModel : ReactiveObject
{
private IReadOnlyList<Repository> repositories;
private IReadOnlyList<Repository> _repositories;
public async Task Load(string username)
{
{
this.Repositories = await new Task<IReadOnlyList<Repository>>(() => new List<Repository> { new Repository("Blah"), new Repository("Bleh") });
}
public IReadOnlyList<Repository> Repositories
{
get { return this.repositories; }
private set { this.RaiseAndSetIfChanged(ref this.repositories, value); }
get { return _repositories; }
private set { this.RaiseAndSetIfChanged(ref _repositories, value); }
}
}
}

3
Tests/Perspex.Markup.Xaml.UnitTests/SamplePerspexObject.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Perspex.Xaml.Base.UnitTest

35
Tests/Perspex.Markup.Xaml.UnitTests/TypeProviderMock.cs

@ -1,21 +1,24 @@
namespace Perspex.Xaml.Base.UnitTest
{
using OmniXaml;
using System;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using OmniXaml;
using System;
class TypeProviderMock : ITypeProvider
namespace Perspex.Xaml.Base.UnitTest
{
internal class TypeProviderMock : ITypeProvider
{
private readonly string typeName;
private readonly string clrNamespace;
private readonly string assemblyName;
private readonly Type typeToReturn;
private readonly string _typeName;
private readonly string _clrNamespace;
private readonly string _assemblyName;
private readonly Type _typeToReturn;
public TypeProviderMock(string typeName, string clrNamespace, string assemblyName, Type typeToReturn)
{
this.typeName = typeName;
this.clrNamespace = clrNamespace;
this.assemblyName = assemblyName;
this.typeToReturn = typeToReturn;
_typeName = typeName;
_clrNamespace = clrNamespace;
_assemblyName = assemblyName;
_typeToReturn = typeToReturn;
}
public TypeProviderMock()
@ -24,10 +27,10 @@
public Type GetType(string typeName, string clrNamespace, string assemblyName)
{
if (this.typeName == typeName && this.clrNamespace == clrNamespace && this.assemblyName == assemblyName)
if (_typeName == typeName && _clrNamespace == clrNamespace && _assemblyName == assemblyName)
{
return typeToReturn;
}
return _typeToReturn;
}
throw new TypeNotFoundException("The Type cannot be found");
}

19
Tests/Perspex.Markup.Xaml.UnitTests/ViewModelMock.cs

@ -1,29 +1,32 @@
using System.ComponentModel;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Perspex.Xaml.Base.UnitTest
{
class ViewModelMock : INotifyPropertyChanged
internal class ViewModelMock : INotifyPropertyChanged
{
private string str;
private int intProp;
private string _str;
private int _intProp;
public int IntProp
{
get { return intProp; }
get { return _intProp; }
set
{
intProp = value;
_intProp = value;
OnPropertyChanged();
}
}
public string StrProp
{
get { return str; }
get { return _str; }
set
{
str = value;
_str = value;
OnPropertyChanged();
}
}

15
Tests/Perspex.Markup.Xaml.UnitTests/XamlBindingTest.cs

@ -1,10 +1,13 @@
namespace Perspex.Xaml.Base.UnitTest
{
using Moq;
using Markup.Xaml.DataBinding;
using OmniXaml.TypeConversion;
using Xunit;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Moq;
using Perspex.Markup.Xaml.DataBinding;
using OmniXaml.TypeConversion;
using Xunit;
namespace Perspex.Xaml.Base.UnitTest
{
public class XamlBindingTest
{
[Fact]

13
Tests/Perspex.SceneGraph.UnitTests/Media/BrushTests.cs

@ -1,15 +1,12 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Media;
using Xunit;
namespace Perspex.SceneGraph.UnitTests.Media
{
using System;
using Perspex.Media;
using Xunit;
public class BrushTests
{
[Fact]

13
Tests/Perspex.SceneGraph.UnitTests/Media/ColorTests.cs

@ -1,15 +1,12 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Media;
using Xunit;
namespace Perspex.SceneGraph.UnitTests.Media
{
using System;
using Perspex.Media;
using Xunit;
public class ColorTests
{
[Fact]

9
Tests/Perspex.SceneGraph.UnitTests/ThicknessTests.cs

@ -1,13 +1,10 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Xunit;
namespace Perspex.SceneGraph.UnitTests.Media
{
using Xunit;
public class ThicknessTests
{
[Fact]

13
samples/TestApplication/App.cs

@ -1,9 +1,12 @@
namespace TestApplication
{
using System;
using Perspex;
using Perspex.Themes.Default;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex;
using Perspex.Themes.Default;
namespace TestApplication
{
public class App : Application
{
public App()

31
samples/TestApplication/Program.cs

@ -1,4 +1,7 @@
using System;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reactive.Linq;
using Perspex;
using Perspex.Animation;
@ -18,13 +21,13 @@ using ReactiveUI;
namespace TestApplication
{
class Item
internal class Item
{
public string Name { get; set; }
public string Value { get; set; }
}
class Node
internal class Node
{
public Node()
{
@ -35,9 +38,9 @@ namespace TestApplication
public PerspexList<Node> Children { get; set; }
}
class Program
internal class Program
{
private static PerspexList<Node> treeData = new PerspexList<Node>
private static PerspexList<Node> s_treeData = new PerspexList<Node>
{
new Node
{
@ -75,7 +78,7 @@ namespace TestApplication
},
};
private static PerspexList<Item> listBoxData = new PerspexList<Item>
private static PerspexList<Item> s_listBoxData = new PerspexList<Item>
{
new Item { Name = "Item 1", Value = "Item 1 Value" },
new Item { Name = "Item 2", Value = "Item 2 Value" },
@ -87,7 +90,7 @@ namespace TestApplication
new Item { Name = "Item 8", Value = "Item 8 Value" },
};
static void Main(string[] args)
private static void Main(string[] args)
{
//Log.Logger = new LoggerConfiguration()
// .Filter.ByIncludingOnly(Matching.WithProperty("Area", "Layout"))
@ -264,7 +267,7 @@ namespace TestApplication
var showDialog = ReactiveCommand.Create();
Button showDialogButton;
var result = new TabItem
{
Header = "Buttons",
@ -356,7 +359,7 @@ namespace TestApplication
close.Subscribe(x => dialog.Close(x));
showDialogButton.Content = await dialog.ShowDialog<string>();
showDialogButton.Content = await dialog.ShowDialog<string>();
});
return result;
@ -402,7 +405,7 @@ namespace TestApplication
new TextBox
{
AcceptsReturn = true,
Text = "A wrapping text box. " +
Text = "A wrapping text box. " +
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin venenatis dui quis libero suscipit tincidunt. " +
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin venenatis dui quis libero suscipit tincidunt.",
TextWrapping = TextWrapping.Wrap,
@ -488,17 +491,17 @@ namespace TestApplication
new TreeView
{
Name = "treeView",
Items = treeData,
Items = s_treeData,
},
(listBox = new ListBox
{
Items = listBoxData,
Items = s_listBoxData,
MaxHeight = 300,
}),
new DropDown
{
Items = listBoxData,
SelectedItem = listBoxData[0],
Items = s_listBoxData,
SelectedItem = s_listBoxData[0],
VerticalAlignment = VerticalAlignment.Center,
}
}

7
samples/TestApplication/Properties/AssemblyInfo.cs

@ -1,4 +1,7 @@
using System.Reflection;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -10,7 +13,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestApplication")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyCopyright("Copyright \u00A9 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

13
samples/XamlTestApplication/App.cs

@ -1,9 +1,12 @@
namespace XamlTestApplication
{
using System;
using Perspex;
using Perspex.Themes.Default;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex;
using Perspex.Themes.Default;
namespace XamlTestApplication
{
public class App : Application
{
public App()

25
samples/XamlTestApplication/MainViewModel.cs

@ -1,15 +1,18 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using ReactiveUI;
namespace XamlTestApplication
{
using System.Collections.Generic;
using ReactiveUI;
public class MainViewModel : ReactiveObject
{
private string name;
private string _name;
public MainViewModel()
{
Name = "José Manuel";
Name = "Jos\u00E9 Manuel";
People = new List<Person>
{
new Person("a little bit of Monica in my life"),
@ -24,8 +27,8 @@ namespace XamlTestApplication
public string Name
{
get { return name; }
set { this.RaiseAndSetIfChanged(ref name, value); }
get { return _name; }
set { this.RaiseAndSetIfChanged(ref _name, value); }
}
public List<Person> People { get; set; }
@ -33,17 +36,17 @@ namespace XamlTestApplication
public class Person
{
private string name;
private string _name;
public Person(string name)
{
this.name = name;
_name = name;
}
public string Name
{
get { return name; }
set { name = value; }
get { return _name; }
set { _name = value; }
}
}
}

37
samples/XamlTestApplication/Program.cs

@ -1,22 +1,25 @@
namespace XamlTestApplication
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Diagnostics;
using System.Windows.Threading;
using Perspex;
using Perspex.Collections;
using Perspex.Controls;
using Perspex.Controls.Templates;
using ReactiveUI;
using XamlTestApplication.Views;
namespace XamlTestApplication
{
using System;
using System.Diagnostics;
using System.Windows.Threading;
using Perspex;
using Perspex.Collections;
using Perspex.Controls;
using Perspex.Controls.Templates;
using ReactiveUI;
using Views;
class Item
internal class Item
{
public string Name { get; set; }
public string Value { get; set; }
}
class Node
internal class Node
{
public Node()
{
@ -27,9 +30,9 @@
public PerspexList<Node> Children { get; set; }
}
class Program
internal class Program
{
static void Main()
private static void Main()
{
var foo = Dispatcher.CurrentDispatcher;
@ -46,10 +49,10 @@
var testCommand = ReactiveCommand.Create();
testCommand.Subscribe(_ => Debug.WriteLine("Test command executed."));
var window = new MainWindow();
window.Show();
Application.Current.Run(window);
}
}
}
}

7
samples/XamlTestApplication/Properties/AssemblyInfo.cs

@ -1,4 +1,7 @@
using System.Reflection;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -10,7 +13,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestApplication")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyCopyright("Copyright \u00A9 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

25
samples/XamlTestApplication/Views/MainWindow.cs

@ -1,15 +1,18 @@
namespace XamlTestApplication.Views
{
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using OmniXaml;
using Perspex.Controls;
using Perspex.Diagnostics;
using Perspex.Markup.Xaml;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using OmniXaml;
using Perspex.Controls;
using Perspex.Diagnostics;
using Perspex.Markup.Xaml;
namespace XamlTestApplication.Views
{
public class MainWindow : Window
{
public MainWindow()

7
src/Gtk/Perspex.Cairo/CairoExtensions.cs

@ -1,8 +1,5 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Cairo
{

29
src/Gtk/Perspex.Cairo/CairoPlatform.cs

@ -1,28 +1,25 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Cairo.Media;
using Perspex.Cairo.Media.Imaging;
using Perspex.Media;
using Perspex.Platform;
using Splat;
namespace Perspex.Cairo
{
using System;
using global::Cairo;
using Perspex.Cairo.Media;
using Perspex.Cairo.Media.Imaging;
using Perspex.Media;
using Perspex.Platform;
using Perspex.Threading;
using Splat;
public class CairoPlatform : IPlatformRenderInterface
{
private static CairoPlatform instance = new CairoPlatform();
private static CairoPlatform s_instance = new CairoPlatform();
public static void Initialize()
{
var locator = Locator.CurrentMutable;
locator.Register(() => instance, typeof(IPlatformRenderInterface));
locator.Register(() => s_instance, typeof(IPlatformRenderInterface));
}
public IBitmapImpl CreateBitmap(int width, int height)
@ -31,9 +28,9 @@ namespace Perspex.Cairo
}
public IFormattedTextImpl CreateFormattedText(
string text,
string fontFamily,
double fontSize,
string text,
string fontFamily,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
Perspex.Media.FontWeight fontWeight)

92
src/Gtk/Perspex.Cairo/Media/DrawingContext.cs

@ -1,19 +1,15 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reactive.Disposables;
using Perspex.Cairo.Media.Imaging;
using Perspex.Media;
using IBitmap = Perspex.Media.Imaging.IBitmap;
namespace Perspex.Cairo.Media
{
using System;
using System.Reactive.Disposables;
using Perspex.Cairo.Media.Imaging;
using Perspex.Media;
using Perspex.Platform;
using Splat;
using Cairo = global::Cairo;
using IBitmap = Perspex.Media.Imaging.IBitmap;
using System.Collections.Generic;
/// <summary>
/// Draws using Direct2D1.
@ -23,15 +19,15 @@ namespace Perspex.Cairo.Media
/// <summary>
/// The cairo context.
/// </summary>
private Cairo.Context context;
private Cairo.Context _context;
/// <summary>
/// Initializes a new instance of the <see cref="DrawingContext"/> class.
/// </summary>
/// <param name="surface">The target surface.</param>
public DrawingContext(Cairo.Surface surface)
{
this.context = new Cairo.Context(surface);
_context = new Cairo.Context(surface);
this.CurrentTransform = Matrix.Identity;
}
@ -41,7 +37,7 @@ namespace Perspex.Cairo.Media
/// <param name="surface">The GDK drawable.</param>
public DrawingContext(Gdk.Drawable drawable)
{
this.context = Gdk.CairoHelper.Create(drawable);
_context = Gdk.CairoHelper.Create(drawable);
this.CurrentTransform = Matrix.Identity;
}
@ -56,7 +52,7 @@ namespace Perspex.Cairo.Media
/// </summary>
public void Dispose()
{
this.context.Dispose();
_context.Dispose();
}
public void DrawImage(IBitmap bitmap, double opacity, Rect sourceRect, Rect destRect)
@ -66,12 +62,12 @@ namespace Perspex.Cairo.Media
var scaleX = destRect.Size.Width / sourceRect.Size.Width;
var scaleY = destRect.Size.Height / sourceRect.Size.Height;
this.context.Save();
this.context.Scale(scaleX, scaleY);
this.context.SetSourceSurface(impl.Surface, (int)sourceRect.X, (int)sourceRect.Y);
this.context.Rectangle(sourceRect.ToCairo());
this.context.Fill();
this.context.Restore();
_context.Save();
_context.Scale(scaleX, scaleY);
_context.SetSourceSurface(impl.Surface, (int)sourceRect.X, (int)sourceRect.Y);
_context.Rectangle(sourceRect.ToCairo());
_context.Fill();
_context.Restore();
}
/// <summary>
@ -83,12 +79,12 @@ namespace Perspex.Cairo.Media
public void DrawLine(Pen pen, Perspex.Point p1, Perspex.Point p2)
{
var size = new Rect(p1, p2).Size;
this.SetBrush(pen.Brush, size);
this.context.LineWidth = pen.Thickness;
this.context.MoveTo(p1.ToCairo());
this.context.LineTo(p2.ToCairo());
this.context.Stroke();
_context.LineWidth = pen.Thickness;
_context.MoveTo(p1.ToCairo());
_context.LineTo(p2.ToCairo());
_context.Stroke();
}
/// <summary>
@ -100,26 +96,26 @@ namespace Perspex.Cairo.Media
public void DrawGeometry(Perspex.Media.Brush brush, Perspex.Media.Pen pen, Perspex.Media.Geometry geometry)
{
var impl = geometry.PlatformImpl as StreamGeometryImpl;
using (var pop = this.PushTransform(impl.Transform))
{
this.context.AppendPath(impl.Path);
_context.AppendPath(impl.Path);
if (brush != null)
{
this.SetBrush(brush, geometry.Bounds.Size);
if (pen != null)
this.context.FillPreserve();
_context.FillPreserve();
else
this.context.Fill();
_context.Fill();
}
if (pen != null)
{
this.SetPen(pen, geometry.Bounds.Size);
this.context.Stroke();
_context.Stroke();
}
}
}
@ -132,8 +128,8 @@ namespace Perspex.Cairo.Media
public void DrawRectange(Pen pen, Rect rect, float cornerRadius)
{
this.SetPen(pen, rect.Size);
this.context.Rectangle(rect.ToCairo());
this.context.Stroke();
_context.Rectangle(rect.ToCairo());
_context.Stroke();
}
/// <summary>
@ -146,9 +142,9 @@ namespace Perspex.Cairo.Media
{
var layout = ((FormattedTextImpl)text.PlatformImpl).Layout;
this.SetBrush(foreground, new Size(0, 0));
this.context.MoveTo(origin.X, origin.Y);
Pango.CairoHelper.ShowLayout(this.context, layout);
_context.MoveTo(origin.X, origin.Y);
Pango.CairoHelper.ShowLayout(_context, layout);
}
/// <summary>
@ -159,8 +155,8 @@ namespace Perspex.Cairo.Media
public void FillRectange(Perspex.Media.Brush brush, Rect rect, float cornerRadius)
{
this.SetBrush(brush, rect.Size);
this.context.Rectangle(rect.ToCairo());
this.context.Fill();
_context.Rectangle(rect.ToCairo());
_context.Fill();
}
/// <summary>
@ -170,10 +166,10 @@ namespace Perspex.Cairo.Media
/// <returns>A disposable used to undo the clip rectangle.</returns>
public IDisposable PushClip(Rect clip)
{
this.context.Rectangle(clip.ToCairo());
this.context.Clip();
_context.Rectangle(clip.ToCairo());
_context.Clip();
return Disposable.Create(() => this.context.ResetClip());
return Disposable.Create(() => _context.ResetClip());
}
/// <summary>
@ -194,11 +190,11 @@ namespace Perspex.Cairo.Media
/// <returns>A disposable used to undo the transformation.</returns>
public IDisposable PushTransform(Matrix matrix)
{
this.context.Transform(matrix.ToCairo());
_context.Transform(matrix.ToCairo());
return Disposable.Create(() =>
{
this.context.Transform(matrix.Invert().ToCairo());
_context.Transform(matrix.Invert().ToCairo());
});
}
@ -209,7 +205,7 @@ namespace Perspex.Cairo.Media
if (solid != null)
{
this.context.SetSourceRGBA(
_context.SetSourceRGBA(
solid.Color.R / 255.0,
solid.Color.G / 255.0,
solid.Color.B / 255.0,
@ -224,14 +220,14 @@ namespace Perspex.Cairo.Media
g.Extend = Cairo.Extend.Pad;
this.context.SetSource(g);
_context.SetSource(g);
}
}
private void SetPen(Pen pen, Size destinationSize)
{
this.SetBrush(pen.Brush, destinationSize);
this.context.LineWidth = pen.Thickness;
_context.LineWidth = pen.Thickness;
}
}
}

35
src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs

@ -1,18 +1,15 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Perspex.Media;
using Perspex.Platform;
using Splat;
namespace Perspex.Cairo.Media
{
using System;
using System.Collections.Generic;
using System.Linq;
using Perspex.Media;
using Perspex.Platform;
using Splat;
public class FormattedTextImpl : IFormattedTextImpl
{
public FormattedTextImpl(
@ -33,21 +30,21 @@ namespace Perspex.Cairo.Media
Style = (Pango.Style)fontStyle,
Weight = fontWeight.ToCairo()
};
this.Layout.Alignment = textAlignment.ToCairo();
}
private Size size;
private Size _size;
public Size Constraint
{
get
{
return size;
return _size;
}
set
{
this.size = value;
_size = value;
this.Layout.Width = Pango.Units.FromDouble(value.Width);
}
}
@ -95,12 +92,12 @@ namespace Perspex.Cairo.Media
public IEnumerable<Rect> HitTestTextRange(int index, int length)
{
var ranges = new List<Rect>();
for (var i = 0; i < length; i++)
{
ranges.Add(this.HitTestTextPosition(index+i));
ranges.Add(this.HitTestTextPosition(index + i));
}
return ranges;
}
@ -109,7 +106,7 @@ namespace Perspex.Cairo.Media
int width;
int height;
this.Layout.GetPixelSize(out width, out height);
return new Size(width, height);
}

10
src/Gtk/Perspex.Cairo/Media/Imaging/BitmapImpl.cs

@ -1,13 +1,11 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Platform;
namespace Perspex.Cairo.Media.Imaging
{
using System;
using Perspex.Platform;
using Cairo = global::Cairo;
public class BitmapImpl : IBitmapImpl

10
src/Gtk/Perspex.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs

@ -1,13 +1,11 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Platform;
namespace Perspex.Cairo.Media.Imaging
{
using System;
using Perspex.Platform;
using Cairo = global::Cairo;
public class RenderTargetBitmapImpl : BitmapImpl, IRenderTargetBitmapImpl

44
src/Gtk/Perspex.Cairo/Media/StreamGeometryContextImpl.cs

@ -1,25 +1,23 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using Perspex.Media;
using Perspex.Platform;
namespace Perspex.Cairo.Media
{
using Perspex.Media;
using Perspex.Platform;
using System;
using System.Collections.Generic;
using Cairo = global::Cairo;
public class StreamGeometryContextImpl : IStreamGeometryContextImpl
{
private StreamGeometryImpl impl;
private StreamGeometryImpl _impl;
public StreamGeometryContextImpl(StreamGeometryImpl imp)
{
this.impl = imp;
this.surf = new Cairo.ImageSurface(Cairo.Format.Argb32, 0, 0);
this.context = new Cairo.Context(this.surf);
_impl = imp;
_surf = new Cairo.ImageSurface(global::Cairo.Format.Argb32, 0, 0);
_context = new Cairo.Context(_surf);
}
public void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection)
@ -28,36 +26,36 @@ namespace Perspex.Cairo.Media
public void BeginFigure(Point startPoint, bool isFilled)
{
this.context.MoveTo(startPoint.ToCairo());
_context.MoveTo(startPoint.ToCairo());
}
public void BezierTo(Point point1, Point point2, Point point3)
{
this.context.CurveTo(point1.ToCairo(), point2.ToCairo(), point3.ToCairo());
_context.CurveTo(point1.ToCairo(), point2.ToCairo(), point3.ToCairo());
}
public void LineTo(Point point)
{
this.context.LineTo(point.ToCairo());
_context.LineTo(point.ToCairo());
}
private Cairo.Context context;
private Cairo.ImageSurface surf;
private Cairo.Context _context;
private Cairo.ImageSurface _surf;
public void EndFigure(bool isClosed)
{
if (isClosed)
this.context.ClosePath();
_context.ClosePath();
var extents = this.context.StrokeExtents();
this.impl.Bounds = new Rect(extents.X, extents.Y, extents.Width, extents.Height);
this.impl.Path = this.context.CopyPath();
var extents = _context.StrokeExtents();
_impl.Bounds = new Rect(extents.X, extents.Y, extents.Width, extents.Height);
_impl.Path = _context.CopyPath();
}
public void Dispose()
{
context.Dispose();
surf.Dispose();
_context.Dispose();
_surf.Dispose();
}
}
}

40
src/Gtk/Perspex.Cairo/Media/StreamGeometryImpl.cs

@ -1,32 +1,30 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Media;
using Perspex.Platform;
using Splat;
using System.Collections.Generic;
namespace Perspex.Cairo.Media
{
using System;
using Perspex.Media;
using Perspex.Platform;
using Cairo = global::Cairo;
using Splat;
using System.Collections.Generic;
public class StreamGeometryImpl : IStreamGeometryImpl
{
public StreamGeometryImpl()
{
this.impl = new StreamGeometryContextImpl(this);
_impl = new StreamGeometryContextImpl(this);
}
public StreamGeometryImpl(Cairo.Path path)
{
this.impl = new StreamGeometryContextImpl(this);
_impl = new StreamGeometryContextImpl(this);
this.Path = path;
}
public Cairo.Path Path
public global::Cairo.Path Path
{
get;
set;
@ -38,20 +36,20 @@ namespace Perspex.Cairo.Media
set;
}
private StreamGeometryContextImpl impl;
private StreamGeometryContextImpl _impl;
private Matrix transform = Matrix.Identity;
private Matrix _transform = Matrix.Identity;
public Matrix Transform
{
get { return this.transform; }
get { return _transform; }
set
{
if (value != this.Transform)
{
if (!value.IsIdentity)
{
this.transform = value;
}
if (!value.IsIdentity)
{
_transform = value;
}
}
}
}
@ -68,7 +66,7 @@ namespace Perspex.Cairo.Media
public IStreamGeometryContextImpl Open()
{
return this.impl;
return _impl;
}
}
}

9
src/Gtk/Perspex.Cairo/Properties/AssemblyInfo.cs

@ -1,8 +1,5 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection;
using System.Runtime.CompilerServices;
@ -16,7 +13,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Perspex.Cairo")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyCopyright("Copyright \u00A9 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

36
src/Gtk/Perspex.Cairo/Renderer.cs

@ -1,27 +1,24 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Runtime.InteropServices;
using Perspex.Cairo.Media;
using Perspex.Media;
using Perspex.Platform;
using Perspex.Rendering;
namespace Perspex.Cairo
{
using System;
using System.Runtime.InteropServices;
using global::Cairo;
using Perspex.Cairo.Media;
using Perspex.Media;
using Perspex.Platform;
using Perspex.Rendering;
using Matrix = Perspex.Matrix;
/// <summary>
/// A cairo renderer.
/// </summary>
public class Renderer : RendererBase
{
private Surface surface;
private Gdk.Window window;
private Surface _surface;
private Gdk.Window _window;
/// <summary>
/// Initializes a new instance of the <see cref="Renderer"/> class.
@ -35,7 +32,7 @@ namespace Perspex.Cairo
public Renderer(ImageSurface surface)
{
this.surface = surface;
_surface = surface;
}
/// <summary>
@ -47,7 +44,7 @@ namespace Perspex.Cairo
{
// Don't need to do anything here.
}
/// <summary>
/// Creates a cairo surface that targets a platform-specific resource.
@ -56,16 +53,15 @@ namespace Perspex.Cairo
/// <returns>A surface wrapped in an <see cref="IDrawingContext"/>.</returns>
protected override IDrawingContext CreateDrawingContext(IPlatformHandle handle)
{
switch (handle.HandleDescriptor)
{
case "RTB":
return new DrawingContext(this.surface);
return new DrawingContext(_surface);
case "GdkWindow":
if (this.window == null)
this.window = new Gdk.Window(handle.Handle);
if (_window == null)
_window = new Gdk.Window(handle.Handle);
return new DrawingContext(this.window);
return new DrawingContext(_window);
default:
throw new NotSupportedException(string.Format(
"Don't know how to create a Cairo renderer from a '{0}' handle",

19
src/Gtk/Perspex.Gtk/AssetLoader.cs

@ -1,18 +1,15 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using Perspex.Platform;
namespace Perspex.Gtk
{
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using Perspex.Platform;
/// <summary>
/// Loads assets compiled into the application binary.
/// </summary>

20
src/Gtk/Perspex.Gtk/ClipboardImpl.cs

@ -1,14 +1,16 @@
namespace Perspex.Gtk
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Threading.Tasks;
using Gdk;
using Perspex.Input.Platform;
namespace Perspex.Gtk
{
using Gdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Perspex.Input.Platform;
using Gtk = global::Gtk;
class ClipboardImpl : IClipboard
internal class ClipboardImpl : IClipboard
{
private static Gtk.Clipboard GetClipboard() => Gtk.Clipboard.GetForDisplay(Gdk.Display.Default, new Atom(IntPtr.Zero));

36
src/Gtk/Perspex.Gtk/CursorFactory.cs

@ -1,15 +1,16 @@
namespace Perspex.Gtk
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using Gdk;
using Perspex.Input;
using Perspex.Platform;
namespace Perspex.Gtk
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gdk;
using Gtk = global::Gtk;
using Perspex.Input;
using Perspex.Platform;
class CursorFactory : IStandardCursorFactory
internal class CursorFactory : IStandardCursorFactory
{
public static CursorFactory Instance { get; } = new CursorFactory();
@ -17,7 +18,7 @@
{
}
private static readonly Dictionary<StandardCursorType, object> CursorTypeMapping = new Dictionary
private static readonly Dictionary<StandardCursorType, object> s_cursorTypeMapping = new Dictionary
<StandardCursorType, object>
{
{ StandardCursorType.AppStarting, CursorType.Watch },
@ -36,10 +37,10 @@
{ StandardCursorType.Help, Gtk.Stock.Help }
};
private static readonly Dictionary<StandardCursorType, IPlatformHandle> Cache =
private static readonly Dictionary<StandardCursorType, IPlatformHandle> s_cache =
new Dictionary<StandardCursorType, IPlatformHandle>();
Gdk.Cursor GetCursor(object desc)
private Gdk.Cursor GetCursor(object desc)
{
Gdk.Cursor rv;
var name = desc as string;
@ -51,23 +52,22 @@
}
else
{
rv = new Gdk.Cursor((CursorType) desc);
rv = new Gdk.Cursor((CursorType)desc);
}
rv.Owned = false;
return rv;
}
public IPlatformHandle GetCursor(StandardCursorType cursorType)
{
IPlatformHandle rv;
if (!Cache.TryGetValue(cursorType, out rv))
if (!s_cache.TryGetValue(cursorType, out rv))
{
Cache[cursorType] =
s_cache[cursorType] =
rv =
new PlatformHandle(
GetCursor(CursorTypeMapping[cursorType]).Handle,
GetCursor(s_cursorTypeMapping[cursorType]).Handle,
"GTKCURSOR");
}

7
src/Gtk/Perspex.Gtk/GtkExtensions.cs

@ -1,8 +1,5 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Gtk
{

28
src/Gtk/Perspex.Gtk/GtkPlatform.cs

@ -1,22 +1,20 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reactive.Disposables;
using Perspex.Input.Platform;
using Perspex.Input;
using Perspex.Platform;
using Splat;
namespace Perspex.Gtk
{
using System;
using System.Reactive.Disposables;
using Perspex.Input.Platform;
using Perspex.Input;
using Perspex.Platform;
using Splat;
using Gtk = global::Gtk;
public class GtkPlatform : IPlatformThreadingInterface, IPlatformSettings
{
private static GtkPlatform instance = new GtkPlatform();
private static GtkPlatform s_instance = new GtkPlatform();
public GtkPlatform()
{
@ -42,11 +40,11 @@ namespace Perspex.Gtk
var locator = Locator.CurrentMutable;
locator.Register(() => new WindowImpl(), typeof(IWindowImpl));
locator.Register(() => new PopupImpl(), typeof(IPopupImpl));
locator.Register(() => new ClipboardImpl(), typeof (IClipboard));
locator.Register(() => new ClipboardImpl(), typeof(IClipboard));
locator.Register(() => CursorFactory.Instance, typeof(IStandardCursorFactory));
locator.Register(() => GtkKeyboardDevice.Instance, typeof(IKeyboardDevice));
locator.Register(() => instance, typeof(IPlatformSettings));
locator.Register(() => instance, typeof(IPlatformThreadingInterface));
locator.Register(() => s_instance, typeof(IPlatformSettings));
locator.Register(() => s_instance, typeof(IPlatformThreadingInterface));
locator.RegisterConstant(new AssetLoader(), typeof(IAssetLoader));
}
@ -64,7 +62,7 @@ namespace Perspex.Gtk
{
var result = true;
var handle = GLib.Timeout.Add(
(uint)interval.TotalMilliseconds,
(uint)interval.TotalMilliseconds,
() =>
{
tick();

33
src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs

@ -1,30 +1,27 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Reflection;
using Perspex.Input;
namespace Perspex.Gtk
{
using System;
using System.Collections.Generic;
using System.Reflection;
using Perspex.Input;
public class GtkKeyboardDevice : KeyboardDevice
{
private static GtkKeyboardDevice instance;
private static readonly Dictionary<Gdk.Key, string> NameDic = new Dictionary<Gdk.Key, string>();
private static GtkKeyboardDevice s_instance;
private static readonly Dictionary<Gdk.Key, string> s_nameDic = new Dictionary<Gdk.Key, string>();
static GtkKeyboardDevice()
{
instance = new GtkKeyboardDevice();
foreach (var f in typeof (Gdk.Key).GetFields(BindingFlags.Public | BindingFlags.Static))
s_instance = new GtkKeyboardDevice();
foreach (var f in typeof(Gdk.Key).GetFields(BindingFlags.Public | BindingFlags.Static))
{
var key = (Gdk.Key) f.GetValue(null);
if(NameDic.ContainsKey(key))
var key = (Gdk.Key)f.GetValue(null);
if (s_nameDic.ContainsKey(key))
continue;
NameDic[key] = f.Name;
s_nameDic[key] = f.Name;
}
}
@ -34,7 +31,7 @@ namespace Perspex.Gtk
public static new GtkKeyboardDevice Instance
{
get { return instance; }
get { return s_instance; }
}
public static Perspex.Input.Key ConvertKey(Gdk.Key key)
@ -47,7 +44,7 @@ namespace Perspex.Gtk
else
{
string s;
if (!NameDic.TryGetValue(key, out s))
if (!s_nameDic.TryGetValue(key, out s))
s = "Unknown";
Perspex.Input.Key result;

19
src/Gtk/Perspex.Gtk/Input/GtkMouseDevice.cs

@ -1,21 +1,18 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Input;
namespace Perspex.Gtk
{
using Perspex.Input;
public class GtkMouseDevice : MouseDevice
{
private static GtkMouseDevice instance;
private static GtkMouseDevice s_instance;
private Point clientPosition;
private Point _clientPosition;
static GtkMouseDevice()
{
instance = new GtkMouseDevice();
s_instance = new GtkMouseDevice();
}
private GtkMouseDevice()
@ -24,12 +21,12 @@ namespace Perspex.Gtk
public static new GtkMouseDevice Instance
{
get { return instance; }
get { return s_instance; }
}
internal void SetClientPosition(Point p)
{
this.clientPosition = p;
_clientPosition = p;
}
}
}

18
src/Gtk/Perspex.Gtk/PopupImpl.cs

@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Gtk;
using Perspex.Platform;
namespace Perspex.Gtk
{
using System;
using Perspex.Platform;
using global::Gtk;
public class PopupImpl : WindowImpl, IPopupImpl
{
public PopupImpl()
: base(WindowType.Popup)
{
{
}
public void SetPosition(Point p)
{
this.Move((int)p.X, (int)p.Y);

7
src/Gtk/Perspex.Gtk/Properties/AssemblyInfo.cs

@ -1,8 +1,5 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection;
using System.Runtime.CompilerServices;

61
src/Gtk/Perspex.Gtk/WindowImpl.cs

@ -1,35 +1,32 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reactive.Disposables;
using Gdk;
using Perspex.Controls;
using Perspex.Input.Raw;
using Perspex.Platform;
using Perspex.Input;
using Action = System.Action;
namespace Perspex.Gtk
{
using System;
using System.Threading.Tasks;
using Perspex.Controls;
using Perspex.Input.Raw;
using Perspex.Platform;
using Gtk = global::Gtk;
using System.Reactive.Disposables;
public class WindowImpl : Gtk.Window, IWindowImpl
{
private TopLevel owner;
private TopLevel _owner;
private IPlatformHandle windowHandle;
private IPlatformHandle _windowHandle;
private Size clientSize;
private Size _clientSize;
private Gtk.IMContext imContext;
private Gtk.IMContext _imContext;
private uint lastKeyEventTimestamp;
private uint _lastKeyEventTimestamp;
private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr);
private static readonly Gdk.Cursor s_defaultCursor = new Gdk.Cursor(CursorType.LeftPtr);
public WindowImpl()
: base(Gtk.WindowType.Toplevel)
@ -49,9 +46,9 @@ namespace Perspex.Gtk
this.Events = Gdk.EventMask.PointerMotionMask |
Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask;
this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
this.imContext = new Gtk.IMMulticontext();
this.imContext.Commit += ImContext_Commit;
_windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
_imContext = new Gtk.IMMulticontext();
_imContext.Commit += ImContext_Commit;
}
public Size ClientSize
@ -62,7 +59,7 @@ namespace Perspex.Gtk
IPlatformHandle ITopLevelImpl.Handle
{
get { return this.windowHandle; }
get { return _windowHandle; }
}
public Action Activated { get; set; }
@ -93,13 +90,13 @@ namespace Perspex.Gtk
{
int x, y;
this.GdkWindow.GetDeskrelativeOrigin(out x, out y);
return new Point(point.X + x, point.Y + y);
}
public void SetOwner(TopLevel owner)
{
this.owner = owner;
_owner = owner;
}
public void SetTitle(string title)
@ -110,7 +107,7 @@ namespace Perspex.Gtk
public void SetCursor(IPlatformHandle cursor)
{
GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor;
GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : s_defaultCursor;
}
public IDisposable ShowDialog()
@ -144,7 +141,7 @@ namespace Perspex.Gtk
var e = new RawMouseEventArgs(
GtkMouseDevice.Instance,
evnt.Time,
this.owner,
_owner,
RawMouseEventType.LeftButtonDown,
new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State));
this.Input(e);
@ -156,7 +153,7 @@ namespace Perspex.Gtk
var e = new RawMouseEventArgs(
GtkMouseDevice.Instance,
evnt.Time,
this.owner,
_owner,
RawMouseEventType.LeftButtonUp,
new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State));
this.Input(e);
@ -166,8 +163,8 @@ namespace Perspex.Gtk
protected override bool OnConfigureEvent(Gdk.EventConfigure evnt)
{
var newSize = new Size(evnt.Width, evnt.Height);
if (newSize != this.clientSize)
if (newSize != _clientSize)
{
this.Resized(newSize);
}
@ -182,8 +179,8 @@ namespace Perspex.Gtk
private bool ProcessKeyEvent(Gdk.EventKey evnt)
{
this.lastKeyEventTimestamp = evnt.Time;
if (this.imContext.FilterKeypress(evnt))
_lastKeyEventTimestamp = evnt.Time;
if (_imContext.FilterKeypress(evnt))
return true;
var e = new RawKeyEventArgs(
GtkKeyboardDevice.Instance,
@ -200,7 +197,7 @@ namespace Perspex.Gtk
private void ImContext_Commit(object o, Gtk.CommitArgs args)
{
this.Input(new RawTextInputEventArgs(GtkKeyboardDevice.Instance, this.lastKeyEventTimestamp, args.Str));
this.Input(new RawTextInputEventArgs(GtkKeyboardDevice.Instance, _lastKeyEventTimestamp, args.Str));
}
protected override bool OnExposeEvent(Gdk.EventExpose evnt)
@ -223,7 +220,7 @@ namespace Perspex.Gtk
var e = new RawMouseEventArgs(
GtkMouseDevice.Instance,
evnt.Time,
this.owner,
_owner,
RawMouseEventType.Move,
position, GetModifierKeys(evnt.State));
this.Input(e);

27
src/Markup/Perspex.Markup.Xaml/Context/PerspexObjectAssembler.cs

@ -1,19 +1,16 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using OmniXaml;
using OmniXaml.ObjectAssembler;
using Perspex.Markup.Xaml.Templates;
namespace Perspex.Markup.Xaml.Context
{
using System;
using OmniXaml;
using OmniXaml.ObjectAssembler;
using Templates;
public class PerspexObjectAssembler : IObjectAssembler
{
private readonly TemplateHostingObjectAssembler objectAssembler;
private readonly TemplateHostingObjectAssembler _objectAssembler;
public PerspexObjectAssembler(IWiringContext wiringContext, ObjectAssemblerSettings objectAssemblerSettings = null)
{
@ -21,24 +18,24 @@ namespace Perspex.Markup.Xaml.Context
mapping.Map<XamlDataTemplate>(template => template.Content, new TemplateLoader());
var assembler = new ObjectAssembler(wiringContext, new TopDownMemberValueContext(), objectAssemblerSettings);
this.objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping);
_objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping);
}
public object Result => this.objectAssembler.Result;
public object Result => _objectAssembler.Result;
public EventHandler<XamlSetValueEventArgs> XamlSetValueHandler { get; set; }
public IWiringContext WiringContext => this.objectAssembler.WiringContext;
public IWiringContext WiringContext => _objectAssembler.WiringContext;
public void Process(XamlInstruction node)
{
this.objectAssembler.Process(node);
_objectAssembler.Process(node);
}
public void OverrideInstance(object instance)
{
this.objectAssembler.OverrideInstance(instance);
_objectAssembler.OverrideInstance(instance);
}
}
}

27
src/Markup/Perspex.Markup.Xaml/Context/PerspexParserFactory.cs

@ -1,19 +1,16 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using OmniXaml;
using OmniXaml.ObjectAssembler;
using OmniXaml.Parsers.ProtoParser;
using OmniXaml.Parsers.XamlInstructions;
namespace Perspex.Markup.Xaml.Context
{
using OmniXaml;
using OmniXaml.ObjectAssembler;
using OmniXaml.Parsers.ProtoParser;
using OmniXaml.Parsers.XamlInstructions;
public class PerspexParserFactory : IXamlParserFactory
{
private readonly IWiringContext wiringContext;
private readonly IWiringContext _wiringContext;
public PerspexParserFactory()
: this(new TypeFactory())
@ -22,7 +19,7 @@ namespace Perspex.Markup.Xaml.Context
public PerspexParserFactory(ITypeFactory typeFactory)
{
this.wiringContext = new PerspexWiringContext(typeFactory);
_wiringContext = new PerspexWiringContext(typeFactory);
}
public IXamlParser CreateForReadingFree()
@ -34,10 +31,10 @@ namespace Perspex.Markup.Xaml.Context
private IXamlParser CreateParser(IObjectAssembler objectAssemblerForUndefinedRoot)
{
var xamlInstructionParser = new OrderAwareXamlInstructionParser(new XamlInstructionParser(this.wiringContext));
var xamlInstructionParser = new OrderAwareXamlInstructionParser(new XamlInstructionParser(_wiringContext));
var phaseParserKit = new PhaseParserKit(
new XamlProtoInstructionParser(this.wiringContext),
new XamlProtoInstructionParser(_wiringContext),
xamlInstructionParser,
objectAssemblerForUndefinedRoot);
@ -46,7 +43,7 @@ namespace Perspex.Markup.Xaml.Context
private IObjectAssembler GetObjectAssemblerForUndefinedRoot()
{
return new ObjectAssembler(this.wiringContext, new TopDownMemberValueContext());
return new ObjectAssembler(_wiringContext, new TopDownMemberValueContext());
}
public IXamlParser CreateForReadingSpecificInstance(object rootInstance)
@ -58,7 +55,7 @@ namespace Perspex.Markup.Xaml.Context
private IObjectAssembler GetObjectAssemblerForSpecificRoot(object rootInstance)
{
return new PerspexObjectAssembler(this.wiringContext, new ObjectAssemblerSettings { RootInstance = rootInstance });
return new PerspexObjectAssembler(_wiringContext, new ObjectAssemblerSettings { RootInstance = rootInstance });
}
}
}

27
src/Markup/Perspex.Markup.Xaml/Context/PerspexTypeRepository.cs

@ -1,35 +1,32 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Glass;
using OmniXaml;
using OmniXaml.Typing;
using Perspex.Markup.Xaml.DataBinding;
namespace Perspex.Markup.Xaml.Context
{
using System;
using DataBinding;
using Glass;
using OmniXaml;
using OmniXaml.Typing;
public class PerspexTypeRepository : XamlTypeRepository
{
private readonly ITypeFactory typeFactory;
private readonly IPerspexPropertyBinder propertyBinder;
private readonly ITypeFactory _typeFactory;
private readonly IPerspexPropertyBinder _propertyBinder;
public PerspexTypeRepository(IXamlNamespaceRegistry xamlNamespaceRegistry,
ITypeFactory typeFactory,
ITypeFeatureProvider featureProvider,
IPerspexPropertyBinder propertyBinder) : base(xamlNamespaceRegistry, typeFactory, featureProvider)
{
this.typeFactory = typeFactory;
this.propertyBinder = propertyBinder;
_typeFactory = typeFactory;
_propertyBinder = propertyBinder;
}
public override XamlType GetXamlType(Type type)
{
Guard.ThrowIfNull(type, nameof(type));
return new PerspexXamlType(type, this, this.typeFactory, this.FeatureProvider, this.propertyBinder);
return new PerspexXamlType(type, this, _typeFactory, this.FeatureProvider, _propertyBinder);
}
}
}

47
src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs

@ -1,30 +1,27 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using Glass;
using OmniXaml;
using OmniXaml.Builder;
using OmniXaml.TypeConversion;
using OmniXaml.Typing;
using Perspex.Controls;
using Perspex.Markup.Xaml.Templates;
using Perspex.Markup.Xaml.Converters;
using Perspex.Markup.Xaml.DataBinding;
using Perspex.Markup.Xaml.MarkupExtensions;
using Perspex.Media;
using Perspex.Media.Imaging;
namespace Perspex.Markup.Xaml.Context
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using Controls;
using Converters;
using DataBinding;
using Glass;
using MarkupExtensions;
using Media;
using Media.Imaging;
using OmniXaml;
using OmniXaml.Builder;
using OmniXaml.TypeConversion;
using OmniXaml.Typing;
using Templates;
public class PerspexWiringContext : IWiringContext
{
private readonly WiringContext context;
private readonly WiringContext _context;
private const string PerspexNs = "https://github.com/grokys/Perspex";
public PerspexWiringContext(ITypeFactory typeFactory)
@ -35,7 +32,7 @@ namespace Perspex.Markup.Xaml.Context
var perspexPropertyBinder = new PerspexPropertyBinder(featureProvider.ConverterProvider);
var xamlTypeRepository = new PerspexTypeRepository(xamlNamespaceRegistry, typeFactory, featureProvider, perspexPropertyBinder);
var typeContext = new TypeContext(xamlTypeRepository, xamlNamespaceRegistry, typeFactory);
this.context = new WiringContext(typeContext, featureProvider);
_context = new WiringContext(typeContext, featureProvider);
}
private static XamlNamespaceRegistry CreateXamlNamespaceRegistry()
@ -114,8 +111,8 @@ namespace Perspex.Markup.Xaml.Context
return contentPropertyProvider;
}
public ITypeContext TypeContext => this.context.TypeContext;
public ITypeContext TypeContext => _context.TypeContext;
public ITypeFeatureProvider FeatureProvider => this.context.FeatureProvider;
public ITypeFeatureProvider FeatureProvider => _context.FeatureProvider;
}
}

19
src/Markup/Perspex.Markup.Xaml/Context/PerspexXamlMember.cs

@ -1,18 +1,15 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Markup.Xaml.DataBinding;
using OmniXaml;
using OmniXaml.Typing;
namespace Perspex.Markup.Xaml.Context
{
using DataBinding;
using OmniXaml;
using OmniXaml.Typing;
public class PerspexXamlMember : XamlMember
{
private readonly IPerspexPropertyBinder propertyBinder;
private readonly IPerspexPropertyBinder _propertyBinder;
public PerspexXamlMember(string name,
XamlType owner,
@ -21,12 +18,12 @@ namespace Perspex.Markup.Xaml.Context
IPerspexPropertyBinder propertyBinder)
: base(name, owner, xamlTypeRepository, featureProvider)
{
this.propertyBinder = propertyBinder;
_propertyBinder = propertyBinder;
}
protected override IXamlMemberValuePlugin LookupXamlMemberValueConnector()
{
return new PerspexXamlMemberValuePlugin(this, this.propertyBinder);
return new PerspexXamlMemberValuePlugin(this, _propertyBinder);
}
public override string ToString()

37
src/Markup/Perspex.Markup.Xaml/Context/PerspexXamlMemberValuePlugin.cs

@ -1,27 +1,24 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reactive.Linq;
using Glass;
using OmniXaml.Typing;
using Perspex.Controls;
using Perspex.Markup.Xaml.DataBinding;
namespace Perspex.Markup.Xaml.Context
{
using System;
using System.Reactive.Linq;
using Controls;
using DataBinding;
using Glass;
using OmniXaml.Typing;
public class PerspexXamlMemberValuePlugin : MemberValuePlugin
{
private readonly XamlMember xamlMember;
private readonly IPerspexPropertyBinder propertyBinder;
private readonly XamlMember _xamlMember;
private readonly IPerspexPropertyBinder _propertyBinder;
public PerspexXamlMemberValuePlugin(XamlMember xamlMember, IPerspexPropertyBinder propertyBinder) : base(xamlMember)
{
this.xamlMember = xamlMember;
this.propertyBinder = propertyBinder;
_xamlMember = xamlMember;
_propertyBinder = propertyBinder;
}
public override void SetValue(object instance, object value)
@ -63,7 +60,7 @@ namespace Perspex.Markup.Xaml.Context
private void HandleXamlBindingDefinition(XamlBindingDefinition xamlBindingDefinition)
{
PerspexObject subjectObject = xamlBindingDefinition.Target;
this.propertyBinder.Create(xamlBindingDefinition);
_propertyBinder.Create(xamlBindingDefinition);
var observableForDataContext = subjectObject.GetObservable(Control.DataContextProperty);
observableForDataContext.Where(o => o != null).Subscribe(_ => this.BindToDataContextWhenItsSet(xamlBindingDefinition));
@ -74,7 +71,7 @@ namespace Perspex.Markup.Xaml.Context
var target = definition.Target;
var dataContext = target.DataContext;
var binding = this.propertyBinder.GetBinding(target, definition.TargetProperty);
var binding = _propertyBinder.GetBinding(target, definition.TargetProperty);
binding.BindToDataContext(dataContext);
}
@ -83,8 +80,8 @@ namespace Perspex.Markup.Xaml.Context
{
get
{
var underlyingType = this.xamlMember.DeclaringType.UnderlyingType;
var name = this.xamlMember.Name + "Property";
var underlyingType = _xamlMember.DeclaringType.UnderlyingType;
var name = _xamlMember.Name + "Property";
var value = ReflectionExtensions.GetValueOfStaticField(underlyingType, name);
return value as PerspexProperty;
@ -100,7 +97,7 @@ namespace Perspex.Markup.Xaml.Context
public override string ToString()
{
return $"{{Perspex Value Connector for member {this.xamlMember}}}";
return $"{{Perspex Value Connector for member {_xamlMember}}}";
}
}
}

23
src/Markup/Perspex.Markup.Xaml/Context/PerspexXamlType.cs

@ -1,19 +1,16 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using OmniXaml;
using OmniXaml.Typing;
using Perspex.Markup.Xaml.DataBinding;
namespace Perspex.Markup.Xaml.Context
{
using System;
using DataBinding;
using OmniXaml;
using OmniXaml.Typing;
public class PerspexXamlType : XamlType
{
private readonly IPerspexPropertyBinder propertyBinder;
private readonly IPerspexPropertyBinder _propertyBinder;
public PerspexXamlType(Type type,
IXamlTypeRepository typeRepository,
@ -21,14 +18,14 @@ namespace Perspex.Markup.Xaml.Context
ITypeFeatureProvider featureProvider,
IPerspexPropertyBinder propertyBinder) : base(type, typeRepository, typeFactory, featureProvider)
{
this.propertyBinder = propertyBinder;
_propertyBinder = propertyBinder;
}
protected IPerspexPropertyBinder PropertyBinder => this.propertyBinder;
protected IPerspexPropertyBinder PropertyBinder => _propertyBinder;
protected override XamlMember LookupMember(string name)
{
return new PerspexXamlMember(name, this, this.TypeRepository, this.FeatureProvider, this.propertyBinder);
return new PerspexXamlMember(name, this, this.TypeRepository, this.FeatureProvider, _propertyBinder);
}
public override string ToString()

15
src/Markup/Perspex.Markup.Xaml/Converters/BitmapConverter.cs

@ -1,16 +1,13 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
using Perspex.Media.Imaging;
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using Media.Imaging;
using OmniXaml.TypeConversion;
public class BitmapConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)

15
src/Markup/Perspex.Markup.Xaml/Converters/BrushConverter.cs

@ -1,16 +1,13 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
using Perspex.Media;
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using Media;
using OmniXaml.TypeConversion;
public class BrushConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)

15
src/Markup/Perspex.Markup.Xaml/Converters/ColumnDefinitionsTypeConverter.cs

@ -1,16 +1,13 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
using Perspex.Controls;
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using Controls;
using OmniXaml.TypeConversion;
public class ColumnDefinitionsTypeConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)

15
src/Markup/Perspex.Markup.Xaml/Converters/GridLengthTypeConverter.cs

@ -1,16 +1,13 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
using Perspex.Controls;
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using Controls;
using OmniXaml.TypeConversion;
public class GridLengthTypeConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)

15
src/Markup/Perspex.Markup.Xaml/Converters/RowDefinitionsTypeConverter.cs

@ -1,16 +1,13 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
using Perspex.Controls;
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using Controls;
using OmniXaml.TypeConversion;
public class RowDefinitionsTypeConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)

13
src/Markup/Perspex.Markup.Xaml/Converters/ThicknessConverter.cs

@ -1,15 +1,12 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using OmniXaml.TypeConversion;
public class ThicknessConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)

47
src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/ObservablePropertyBranch.cs

@ -1,33 +1,30 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reactive.Linq;
using System.Reflection;
using Glass;
namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reactive.Linq;
using System.Reflection;
using Glass;
public class ObservablePropertyBranch
{
private readonly object instance;
private readonly PropertyPath propertyPath;
private readonly PropertyMountPoint mountPoint;
private readonly object _instance;
private readonly PropertyPath _propertyPath;
private readonly PropertyMountPoint _mountPoint;
public ObservablePropertyBranch(object instance, PropertyPath propertyPath)
{
Guard.ThrowIfNull(instance, nameof(instance));
Guard.ThrowIfNull(propertyPath, nameof(propertyPath));
this.instance = instance;
this.propertyPath = propertyPath;
this.mountPoint = new PropertyMountPoint(instance, propertyPath);
_instance = instance;
_propertyPath = propertyPath;
_mountPoint = new PropertyMountPoint(instance, propertyPath);
var properties = this.GetPropertiesThatRaiseNotifications();
this.Values = this.CreateUnifiedObservableFromNodes(properties);
}
@ -45,12 +42,12 @@ namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
parentOnPropertyChanged => subscription.Parent.PropertyChanged += parentOnPropertyChanged,
parentOnPropertyChanged => subscription.Parent.PropertyChanged -= parentOnPropertyChanged)
.Where(pattern => pattern.EventArgs.PropertyName == subscription.PropertyName)
.Select(pattern => this.mountPoint.Value);
.Select(pattern => _mountPoint.Value);
}
private IEnumerable<PropertyDefinition> GetPropertiesThatRaiseNotifications()
{
return this.GetSubscriptionsRecursive(this.instance, this.propertyPath, 0);
return this.GetSubscriptionsRecursive(_instance, _propertyPath, 0);
}
private IEnumerable<PropertyDefinition> GetSubscriptionsRecursive(object current, PropertyPath propertyPath, int i)
@ -66,13 +63,13 @@ namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
var nextPropertyName = propertyPath.Chunks[i];
subscriptions.Add(new PropertyDefinition(inpc, nextPropertyName));
if (i < this.propertyPath.Chunks.Length)
if (i < _propertyPath.Chunks.Length)
{
var currentObjectTypeInfo = current.GetType().GetTypeInfo();
var nextProperty = currentObjectTypeInfo.GetDeclaredProperty(nextPropertyName);
var nextInstance = nextProperty.GetValue(current);
if (i < this.propertyPath.Chunks.Length - 1)
if (i < _propertyPath.Chunks.Length - 1)
{
subscriptions.AddRange(this.GetSubscriptionsRecursive(nextInstance, propertyPath, i + 1));
}
@ -85,16 +82,16 @@ namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
{
get
{
return this.mountPoint.Value;
return _mountPoint.Value;
}
set
{
this.mountPoint.Value = value;
_mountPoint.Value = value;
}
}
public Type Type => this.mountPoint.ProperyType;
public Type Type => _mountPoint.ProperyType;
private class PropertyDefinition
{

23
src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/PropertyMountPoint.cs

@ -1,25 +1,22 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reflection;
using Glass;
namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
{
using System;
using System.Reflection;
using Glass;
public class PropertyMountPoint
{
private readonly TargettedProperty referencedTargettedProperty;
private readonly TargettedProperty _referencedTargettedProperty;
public PropertyMountPoint(object origin, PropertyPath propertyPath)
{
Guard.ThrowIfNull(origin, nameof(origin));
Guard.ThrowIfNull(propertyPath, nameof(propertyPath));
this.referencedTargettedProperty = GetReferencedPropertyInfo(origin, propertyPath, 0);
_referencedTargettedProperty = GetReferencedPropertyInfo(origin, propertyPath, 0);
}
private static TargettedProperty GetReferencedPropertyInfo(object current, PropertyPath propertyPath, int level)
@ -41,15 +38,15 @@ namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
{
get
{
return this.referencedTargettedProperty.Value;
return _referencedTargettedProperty.Value;
}
set
{
this.referencedTargettedProperty.Value = value;
_referencedTargettedProperty.Value = value;
}
}
public Type ProperyType => this.referencedTargettedProperty.PropertyType;
public Type ProperyType => _referencedTargettedProperty.PropertyType;
}
}

19
src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/PropertyPath.cs

@ -1,29 +1,26 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
{
public class PropertyPath
{
private string[] chunks;
private string[] _chunks;
private PropertyPath(PropertyPath propertyPath)
{
this.chunks = propertyPath.Chunks;
_chunks = propertyPath.Chunks;
}
public PropertyPath(string path)
{
this.chunks = path.Split('.');
_chunks = path.Split('.');
}
public string[] Chunks
{
get { return this.chunks; }
set { this.chunks = value; }
get { return _chunks; }
set { _chunks = value; }
}
public PropertyPath Clone()
@ -33,7 +30,7 @@ namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
public override string ToString()
{
return string.Join(".", this.chunks);
return string.Join(".", _chunks);
}
}
}

29
src/Markup/Perspex.Markup.Xaml/DataBinding/ChangeTracking/TargettedProperty.cs

@ -1,44 +1,41 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reflection;
using Glass;
namespace Perspex.Markup.Xaml.DataBinding.ChangeTracking
{
using System;
using System.Reflection;
using Glass;
internal class TargettedProperty
{
private readonly object instance;
private readonly PropertyInfo propertyInfo;
private readonly object _instance;
private readonly PropertyInfo _propertyInfo;
public TargettedProperty(object instance, PropertyInfo propertyInfo)
{
Guard.ThrowIfNull(instance, nameof(instance));
Guard.ThrowIfNull(propertyInfo, nameof(propertyInfo));
this.instance = instance;
this.propertyInfo = propertyInfo;
_instance = instance;
_propertyInfo = propertyInfo;
}
public object Value
{
get
{
return this.propertyInfo.GetValue(this.instance);
return _propertyInfo.GetValue(_instance);
}
set
{
this.propertyInfo.SetValue(this.instance, value);
_propertyInfo.SetValue(_instance, value);
}
}
public Type PropertyType => this.propertyInfo.PropertyType;
public Type PropertyType => _propertyInfo.PropertyType;
public string Name => this.propertyInfo.Name;
public string Name => _propertyInfo.Name;
}
}

87
src/Markup/Perspex.Markup.Xaml/DataBinding/DataContextChangeSynchronizer.cs

@ -1,98 +1,95 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Globalization;
using System.Reactive.Linq;
using System.Reflection;
using Glass;
using OmniXaml.TypeConversion;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Markup.Xaml.DataBinding
{
using System;
using System.Globalization;
using System.Reactive.Linq;
using System.Reflection;
using ChangeTracking;
using Glass;
using OmniXaml.TypeConversion;
public class DataContextChangeSynchronizer
{
private readonly BindingTarget bindingTarget;
private readonly ITypeConverter targetPropertyTypeConverter;
private readonly TargetBindingEndpoint bindingEndpoint;
private readonly ObservablePropertyBranch sourceEndpoint;
private readonly BindingTarget _bindingTarget;
private readonly ITypeConverter _targetPropertyTypeConverter;
private readonly TargetBindingEndpoint _bindingEndpoint;
private readonly ObservablePropertyBranch _sourceEndpoint;
public DataContextChangeSynchronizer(BindingSource bindingSource, BindingTarget bindingTarget, ITypeConverterProvider typeConverterProvider)
{
this.bindingTarget = bindingTarget;
_bindingTarget = bindingTarget;
Guard.ThrowIfNull(bindingTarget.Object, nameof(bindingTarget.Object));
Guard.ThrowIfNull(bindingTarget.Property, nameof(bindingTarget.Property));
Guard.ThrowIfNull(bindingSource.SourcePropertyPath, nameof(bindingSource.SourcePropertyPath));
Guard.ThrowIfNull(bindingSource.Source, nameof(bindingSource.Source));
Guard.ThrowIfNull(typeConverterProvider, nameof(typeConverterProvider));
this.bindingEndpoint = new TargetBindingEndpoint(bindingTarget.Object, bindingTarget.Property);
this.sourceEndpoint = new ObservablePropertyBranch(bindingSource.Source, bindingSource.SourcePropertyPath);
this.targetPropertyTypeConverter = typeConverterProvider.GetTypeConverter(bindingTarget.Property.PropertyType);
_bindingEndpoint = new TargetBindingEndpoint(bindingTarget.Object, bindingTarget.Property);
_sourceEndpoint = new ObservablePropertyBranch(bindingSource.Source, bindingSource.SourcePropertyPath);
_targetPropertyTypeConverter = typeConverterProvider.GetTypeConverter(bindingTarget.Property.PropertyType);
}
public class BindingTarget
{
private readonly PerspexObject obj;
private readonly PerspexProperty property;
private readonly PerspexObject _obj;
private readonly PerspexProperty _property;
public BindingTarget(PerspexObject @object, PerspexProperty property)
{
this.obj = @object;
this.property = property;
_obj = @object;
_property = property;
}
public PerspexObject Object => obj;
public PerspexObject Object => _obj;
public PerspexProperty Property => property;
public PerspexProperty Property => _property;
public object Value
{
get { return obj.GetValue(property); }
set { obj.SetValue(property, value); }
get { return _obj.GetValue(_property); }
set { _obj.SetValue(_property, value); }
}
}
public class BindingSource
{
private readonly PropertyPath sourcePropertyPath;
private readonly object source;
private readonly PropertyPath _sourcePropertyPath;
private readonly object _source;
public BindingSource(PropertyPath sourcePropertyPath, object source)
{
this.sourcePropertyPath = sourcePropertyPath;
this.source = source;
_sourcePropertyPath = sourcePropertyPath;
_source = source;
}
public PropertyPath SourcePropertyPath => this.sourcePropertyPath;
public PropertyPath SourcePropertyPath => _sourcePropertyPath;
public object Source => source;
public object Source => _source;
}
public void StartUpdatingTargetWhenSourceChanges()
{
// TODO: commenting out this line will make the existing value to be skipped from the SourceValues. This is not supposed to happen. Is it?
bindingTarget.Value = ConvertedValue(sourceEndpoint.Value, bindingTarget.Property.PropertyType);
_bindingTarget.Value = ConvertedValue(_sourceEndpoint.Value, _bindingTarget.Property.PropertyType);
// We use the native Bind method from PerspexObject to subscribe to the SourceValues observable
this.bindingTarget.Object.Bind(this.bindingTarget.Property, this.SourceValues);
_bindingTarget.Object.Bind(_bindingTarget.Property, this.SourceValues);
}
public void StartUpdatingSourceWhenTargetChanges()
{
// We subscribe to the TargetValues and each time we have a new value, we update the source with it
this.TargetValues.Subscribe(newValue => this.sourceEndpoint.Value = newValue);
this.TargetValues.Subscribe(newValue => _sourceEndpoint.Value = newValue);
}
private IObservable<object> SourceValues
{
get
{
return this.sourceEndpoint.Values.Select(originalValue => this.ConvertedValue(originalValue, this.bindingTarget.Property.PropertyType));
return _sourceEndpoint.Values.Select(originalValue => this.ConvertedValue(originalValue, _bindingTarget.Property.PropertyType));
}
}
@ -100,8 +97,8 @@ namespace Perspex.Markup.Xaml.DataBinding
{
get
{
return this.bindingEndpoint.Object
.GetObservable(this.bindingEndpoint.Property).Select(o => this.ConvertedValue(o, this.sourceEndpoint.Type));
return _bindingEndpoint.Object
.GetObservable(_bindingEndpoint.Property).Select(o => this.ConvertedValue(o, _sourceEndpoint.Type));
}
}
@ -109,8 +106,8 @@ namespace Perspex.Markup.Xaml.DataBinding
{
get
{
var sourceTypeInfo = this.sourceEndpoint.Type.GetTypeInfo();
var targetTypeInfo = this.bindingEndpoint.Property.PropertyType.GetTypeInfo();
var sourceTypeInfo = _sourceEndpoint.Type.GetTypeInfo();
var targetTypeInfo = _bindingEndpoint.Property.PropertyType.GetTypeInfo();
var compatible = targetTypeInfo.IsAssignableFrom(sourceTypeInfo);
return compatible;
}
@ -137,11 +134,11 @@ namespace Perspex.Markup.Xaml.DataBinding
return true;
}
if (this.targetPropertyTypeConverter != null)
if (_targetPropertyTypeConverter != null)
{
if (this.targetPropertyTypeConverter.CanConvertTo(null, targetType))
if (_targetPropertyTypeConverter.CanConvertTo(null, targetType))
{
object convertedValue = this.targetPropertyTypeConverter.ConvertTo(
object convertedValue = _targetPropertyTypeConverter.ConvertTo(
null,
CultureInfo.InvariantCulture,
originalValue,

9
src/Markup/Perspex.Markup.Xaml/DataBinding/IPerspexPropertyBinder.cs

@ -1,13 +1,10 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
namespace Perspex.Markup.Xaml.DataBinding
{
using System.Collections.Generic;
public interface IPerspexPropertyBinder
{
XamlBinding GetBinding(PerspexObject po, PerspexProperty pp);

31
src/Markup/Perspex.Markup.Xaml/DataBinding/PerspexPropertyBinder.cs

@ -1,36 +1,33 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using OmniXaml.TypeConversion;
namespace Perspex.Markup.Xaml.DataBinding
{
using System;
using System.Collections.Generic;
using System.Linq;
using OmniXaml.TypeConversion;
public class PerspexPropertyBinder : IPerspexPropertyBinder
{
private readonly ITypeConverterProvider typeConverterProvider;
private readonly ITypeConverterProvider _typeConverterProvider;
private readonly HashSet<XamlBinding> bindings;
private readonly HashSet<XamlBinding> _bindings;
public PerspexPropertyBinder(ITypeConverterProvider typeConverterProvider)
{
this.typeConverterProvider = typeConverterProvider;
this.bindings = new HashSet<XamlBinding>();
_typeConverterProvider = typeConverterProvider;
_bindings = new HashSet<XamlBinding>();
}
public XamlBinding GetBinding(PerspexObject po, PerspexProperty pp)
{
return this.bindings.First(xamlBinding => xamlBinding.Target == po && xamlBinding.TargetProperty == pp);
return _bindings.First(xamlBinding => xamlBinding.Target == po && xamlBinding.TargetProperty == pp);
}
public IEnumerable<XamlBinding> GetBindings(PerspexObject source)
{
return from binding in this.bindings
return from binding in _bindings
where binding.Target == source
select binding;
}
@ -47,7 +44,7 @@ namespace Perspex.Markup.Xaml.DataBinding
throw new InvalidOperationException();
}
var binding = new XamlBinding(this.typeConverterProvider)
var binding = new XamlBinding(_typeConverterProvider)
{
BindingMode = xamlBinding.BindingMode,
SourcePropertyPath = xamlBinding.SourcePropertyPath,
@ -55,7 +52,7 @@ namespace Perspex.Markup.Xaml.DataBinding
TargetProperty = xamlBinding.TargetProperty
};
this.bindings.Add(binding);
_bindings.Add(binding);
return binding;
}
}

11
src/Markup/Perspex.Markup.Xaml/DataBinding/SourceBindingEndpoint.cs

@ -1,14 +1,11 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.ComponentModel;
namespace Perspex.Markup.Xaml.DataBinding
{
using System;
using System.ComponentModel;
public class SourceBindingEndpoint
{
public Type PropertyType { get; }

7
src/Markup/Perspex.Markup.Xaml/DataBinding/TargetBindingEndpoint.cs

@ -1,8 +1,5 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Markup.Xaml.DataBinding
{

31
src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBinding.cs

@ -1,24 +1,21 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Diagnostics;
using OmniXaml.TypeConversion;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Markup.Xaml.DataBinding
{
using System;
using System.Diagnostics;
using ChangeTracking;
using OmniXaml.TypeConversion;
public class XamlBinding
{
private readonly ITypeConverterProvider typeConverterProvider;
private DataContextChangeSynchronizer changeSynchronizer;
private readonly ITypeConverterProvider _typeConverterProvider;
private DataContextChangeSynchronizer _changeSynchronizer;
public XamlBinding(ITypeConverterProvider typeConverterProvider)
{
this.typeConverterProvider = typeConverterProvider;
_typeConverterProvider = typeConverterProvider;
}
public PerspexObject Target { get; set; }
@ -41,22 +38,22 @@ namespace Perspex.Markup.Xaml.DataBinding
var bindingSource = new DataContextChangeSynchronizer.BindingSource(this.SourcePropertyPath, dataContext);
var bindingTarget = new DataContextChangeSynchronizer.BindingTarget(this.Target, this.TargetProperty);
this.changeSynchronizer = new DataContextChangeSynchronizer(bindingSource, bindingTarget, this.typeConverterProvider);
_changeSynchronizer = new DataContextChangeSynchronizer(bindingSource, bindingTarget, _typeConverterProvider);
if (this.BindingMode == BindingMode.TwoWay)
{
this.changeSynchronizer.StartUpdatingTargetWhenSourceChanges();
this.changeSynchronizer.StartUpdatingSourceWhenTargetChanges();
_changeSynchronizer.StartUpdatingTargetWhenSourceChanges();
_changeSynchronizer.StartUpdatingSourceWhenTargetChanges();
}
if (this.BindingMode == BindingMode.OneWay)
{
this.changeSynchronizer.StartUpdatingTargetWhenSourceChanges();
_changeSynchronizer.StartUpdatingTargetWhenSourceChanges();
}
if (this.BindingMode == BindingMode.OneWayToSource)
{
this.changeSynchronizer.StartUpdatingSourceWhenTargetChanges();
_changeSynchronizer.StartUpdatingSourceWhenTargetChanges();
}
}
catch (Exception e)

35
src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBindingDefinition.cs

@ -1,35 +1,32 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Controls;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Markup.Xaml.DataBinding
{
using ChangeTracking;
using Controls;
public class XamlBindingDefinition
{
private PropertyPath sourcePropertyPath;
private BindingMode bindingMode;
private readonly Control target;
private readonly PerspexProperty targetProperty;
private PropertyPath _sourcePropertyPath;
private BindingMode _bindingMode;
private readonly Control _target;
private readonly PerspexProperty _targetProperty;
public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
{
this.target = target;
this.targetProperty = targetProperty;
this.sourcePropertyPath = sourcePropertyPath;
this.bindingMode = bindingMode;
_target = target;
_targetProperty = targetProperty;
_sourcePropertyPath = sourcePropertyPath;
_bindingMode = bindingMode;
}
public Control Target => this.target;
public Control Target => _target;
public PerspexProperty TargetProperty => this.targetProperty;
public PerspexProperty TargetProperty => _targetProperty;
public PropertyPath SourcePropertyPath => this.sourcePropertyPath;
public PropertyPath SourcePropertyPath => _sourcePropertyPath;
public BindingMode BindingMode => this.bindingMode;
public BindingMode BindingMode => _bindingMode;
}
}

17
src/Markup/Perspex.Markup.Xaml/MarkupExtensions/BindingExtension.cs

@ -1,17 +1,14 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using OmniXaml;
using Perspex.Controls;
using Perspex.Markup.Xaml.DataBinding;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Markup.Xaml.MarkupExtensions
{
using System.Linq;
using Controls;
using DataBinding;
using DataBinding.ChangeTracking;
using OmniXaml;
public class BindingExtension : MarkupExtension
{
public BindingExtension()

17
src/Markup/Perspex.Markup.Xaml/MarkupExtensions/TypeExtension.cs

@ -1,17 +1,14 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Glass;
using OmniXaml;
using OmniXaml.Attributes;
using OmniXaml.Typing;
namespace Perspex.Markup.Xaml.MarkupExtensions
{
using System;
using Glass;
using OmniXaml;
using OmniXaml.Attributes;
using OmniXaml.Typing;
[ContentProperty("TargetType")]
public class TypeExtension : MarkupExtension
{

19
src/Markup/Perspex.Markup.Xaml/PerspexXamlLoader.cs

@ -1,18 +1,15 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reflection;
using OmniXaml;
using Perspex.Markup.Xaml.Context;
using Perspex.Platform;
using Splat;
namespace Perspex.Markup.Xaml
{
using System;
using System.Reflection;
using OmniXaml;
using Perspex.Markup.Xaml.Context;
using Platform;
using Splat;
/// <summary>
/// Loads XAML for a perspex application.
/// </summary>

7
src/Markup/Perspex.Markup.Xaml/Properties/AssemblyInfo.cs

@ -1,8 +1,5 @@

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Reflection;

7
src/Markup/Perspex.Markup.Xaml/Templates/Template.cs

@ -1,8 +1,5 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
namespace Perspex.Markup.Xaml.Templates
{

27
src/Markup/Perspex.Markup.Xaml/Templates/TemplateContent.cs

@ -1,32 +1,29 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using OmniXaml;
using Perspex.Controls;
using Perspex.Markup.Xaml.Context;
namespace Perspex.Markup.Xaml.Templates
{
using System.Collections.Generic;
using Context;
using OmniXaml;
using Perspex.Controls;
public class TemplateContent
{
private readonly IEnumerable<XamlInstruction> nodes;
private readonly IWiringContext context;
private readonly IEnumerable<XamlInstruction> _nodes;
private readonly IWiringContext _context;
public TemplateContent(IEnumerable<XamlInstruction> nodes, IWiringContext context)
{
this.nodes = nodes;
this.context = context;
_nodes = nodes;
_context = context;
}
public Control Load()
{
var assembler = new PerspexObjectAssembler(this.context);
var assembler = new PerspexObjectAssembler(_context);
foreach (var xamlNode in this.nodes)
foreach (var xamlNode in _nodes)
{
assembler.Process(xamlNode);
}

11
src/Markup/Perspex.Markup.Xaml/Templates/TemplateLoader.cs

@ -1,14 +1,11 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using OmniXaml;
namespace Perspex.Markup.Xaml.Templates
{
using System.Collections.Generic;
using OmniXaml;
public class TemplateLoader : IDeferredLoader
{
public object Load(IEnumerable<XamlInstruction> nodes, IWiringContext context)

15
src/Markup/Perspex.Markup.Xaml/Templates/XamlDataTemplate.cs

@ -1,16 +1,13 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using OmniXaml.Attributes;
using Perspex.Controls;
using Perspex.Controls.Templates;
namespace Perspex.Markup.Xaml.Templates
{
using System;
using Controls.Templates;
using OmniXaml.Attributes;
using Perspex.Controls;
[ContentProperty("Content")]
public class XamlDataTemplate : IDataTemplate
{

5
src/NGenerics/Constants.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -9,7 +12,7 @@
namespace NGenerics
{
static class Constants
internal static class Constants
{
public const string NotEnoughSpaceInTheTargetArray = "Not enough space in the target array.";
}

74
src/NGenerics/DataStructures/Comparers/ComparisonComparer.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -20,59 +23,58 @@ namespace NGenerics.Comparers
/// <typeparam name="T">The type of the objects to compare.</typeparam>
//[Serializable]
public sealed class ComparisonComparer<T> : IComparer<T>
{
#region Globals
{
#region Globals
private Comparison<T> _comparison;
private Comparison<T> comparison;
#endregion
#endregion
#region Construction
#region Construction
/// <param name="comparison">The comparison.</param>
/// <exception cref="ArgumentNullException"><paramref name="comparison"/> is a null reference (<c>Nothing</c> in Visual Basic).</exception>
public ComparisonComparer(Comparison<T> comparison)
{
public ComparisonComparer(Comparison<T> comparison)
{
Guard.ArgumentNotNull(comparison, "comparison");
this.comparison = comparison;
}
_comparison = comparison;
}
#endregion
#endregion
#region Public Members
#region Public Members
/// <summary>
/// Gets or sets the comparison used in this comparer.
/// </summary>
/// <summary>
/// Gets or sets the comparison used in this comparer.
/// </summary>
/// <value>The comparison used in this comparer.</value>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is a null reference (<c>Nothing</c> in Visual Basic).</exception>
public Comparison<T> Comparison
{
get
{
return comparison;
}
set
{
public Comparison<T> Comparison
{
get
{
return _comparison;
}
set
{
Guard.ArgumentNotNull(value, "value");
comparison = value;
}
}
_comparison = value;
}
}
#endregion
#endregion
#region IComparer<T> Members
#region IComparer<T> Members
/// <inheritdoc />
public int Compare(T x, T y)
{
return comparison(x, y);
}
/// <inheritdoc />
public int Compare(T x, T y)
{
return _comparison(x, y);
}
#endregion
}
#endregion
}
}

41
src/NGenerics/DataStructures/Comparers/KeyValuePairComparer.cs

@ -1,4 +1,7 @@
/*
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -11,18 +14,19 @@
using System;
using System.Collections.Generic;
namespace NGenerics.Comparers {
namespace NGenerics.Comparers
{
/// <summary>
/// A comparer for comparing keys for the KeyValuePair class.
/// </summary>
/// <typeparam name="TKey">The key type.</typeparam>
/// <typeparam name="TValue">The value type.</typeparam>
//[Serializable]
public class KeyValuePairComparer<TKey, TValue> : IComparer<KeyValuePair<TKey, TValue>> {
public class KeyValuePairComparer<TKey, TValue> : IComparer<KeyValuePair<TKey, TValue>>
{
#region Globals
private readonly IComparer<TKey> comparer;
private readonly IComparer<TKey> _comparer;
#endregion
@ -31,22 +35,23 @@ namespace NGenerics.Comparers {
/// <summary>
/// Initializes a new instance of the <see cref="KeyValuePairComparer&lt;TKey, TValue&gt;"/> class.
/// </summary>
public KeyValuePairComparer() {
comparer = Comparer<TKey>.Default;
public KeyValuePairComparer()
{
_comparer = Comparer<TKey>.Default;
}
/// <summary>
/// Initializes a new instance of the <see cref="KeyValuePairComparer&lt;TKey, TValue&gt;"/> class.
/// </summary>
/// <param name="comparer">The comparer.</param>
public KeyValuePairComparer(IComparer<TKey> comparer) {
public KeyValuePairComparer(IComparer<TKey> comparer)
{
if (comparer == null)
{
throw new ArgumentNullException("comparer");
}
this.comparer = comparer;
_comparer = comparer;
}
/// <summary>
@ -55,11 +60,12 @@ namespace NGenerics.Comparers {
/// <param name="comparison">The comparison.</param>
public KeyValuePairComparer(Comparison<TKey> comparison)
{
if (comparison == null) {
if (comparison == null)
{
throw new ArgumentNullException("comparison");
}
comparer = new ComparisonComparer<TKey>(comparison);
_comparer = new ComparisonComparer<TKey>(comparison);
}
#endregion
@ -67,8 +73,9 @@ namespace NGenerics.Comparers {
#region IComparer<KeyValuePairComparer<TKey,TValue>> Members
/// <inheritdoc />
public int Compare(KeyValuePair<TKey, TValue> x, KeyValuePair<TKey, TValue> y) {
return comparer.Compare(x.Key, y.Key);
public int Compare(KeyValuePair<TKey, TValue> x, KeyValuePair<TKey, TValue> y)
{
return _comparer.Compare(x.Key, y.Key);
}
#endregion
@ -76,11 +83,11 @@ namespace NGenerics.Comparers {
#region IComparer<TKey> Members
/// <inheritdoc />
public int Compare(TKey x, TKey y) {
return comparer.Compare(x, y);
public int Compare(TKey x, TKey y)
{
return _comparer.Compare(x, y);
}
#endregion
}
}

29
src/NGenerics/DataStructures/Comparers/ReverseComparer.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -14,16 +17,16 @@ using NGenerics.Util;
namespace NGenerics.Comparers
{
/// <summary>
/// A comparer that wraps the IComparable interface to reproduce the opposite comparison result.
/// </summary>
/// <typeparam name="T">The type of the objects to compare.</typeparam>
/// <summary>
/// A comparer that wraps the IComparable interface to reproduce the opposite comparison result.
/// </summary>
/// <typeparam name="T">The type of the objects to compare.</typeparam>
//[Serializable]
public sealed class ReverseComparer<T> : IComparer<T>
{
#region Globals
private IComparer<T> comparerToUse;
private IComparer<T> _comparerToUse;
#endregion
@ -31,27 +34,26 @@ namespace NGenerics.Comparers
/// <inheritdoc />
public ReverseComparer()
{
comparerToUse = Comparer<T>.Default;
_comparerToUse = Comparer<T>.Default;
}
/// <param name="comparer">The comparer to reverse.</param>
/// <exception cref="ArgumentNullException"><paramref name="comparer"/> is a null reference (<c>Nothing</c> in Visual Basic).</exception>
public ReverseComparer(IComparer<T> comparer)
{
Guard.ArgumentNotNull(comparer, "comparer");
comparerToUse = comparer;
_comparerToUse = comparer;
}
#endregion
#region IComparer<T> Members
/// <inheritdoc />
/// <inheritdoc />
public int Compare(T x, T y)
{
return (comparerToUse.Compare(y, x));
return (_comparerToUse.Compare(y, x));
}
#endregion
@ -67,14 +69,13 @@ namespace NGenerics.Comparers
{
get
{
return comparerToUse;
return _comparerToUse;
}
set
{
Guard.ArgumentNotNull(value, "value");
comparerToUse = value;
_comparerToUse = value;
}
}

139
src/NGenerics/DataStructures/General/Heap.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -28,10 +31,10 @@ namespace NGenerics.DataStructures.General
{
#region Globals
const string heapIsEmpty = "The heap is empty.";
private readonly List<T> data;
private readonly IComparer<T> comparerToUse;
private readonly HeapType thisType;
private const string heapIsEmpty = "The heap is empty.";
private readonly List<T> _data;
private readonly IComparer<T> _comparerToUse;
private readonly HeapType _thisType;
#endregion
@ -70,7 +73,7 @@ namespace NGenerics.DataStructures.General
/// <param name="type">The type of heap.</param>
/// <param name="comparer">The comparer.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="type"/> is not either <see cref="HeapType.Maximum"/> or <see cref="HeapType.Minimum"/> .</exception>
public Heap(HeapType type, Comparison<T> comparer) : this(type, new ComparisonComparer<T>(comparer)){}
public Heap(HeapType type, Comparison<T> comparer) : this(type, new ComparisonComparer<T>(comparer)) { }
/// <summary>
/// Initializes a new instance of the <see cref="Heap&lt;T&gt;"/> class.
@ -102,11 +105,11 @@ namespace NGenerics.DataStructures.General
throw new ArgumentOutOfRangeException("type");
}
thisType = type;
_thisType = type;
data = new List<T> {default(T)};
_data = new List<T> { default(T) };
comparerToUse = type == HeapType.Minimum ? comparer : new ReverseComparer<T>(comparer);
_comparerToUse = type == HeapType.Minimum ? comparer : new ReverseComparer<T>(comparer);
}
@ -124,11 +127,11 @@ namespace NGenerics.DataStructures.General
{
throw new ArgumentOutOfRangeException("type");
}
thisType = type;
_thisType = type;
data = new List<T>(capacity) {default(T)};
_data = new List<T>(capacity) { default(T) };
comparerToUse = type == HeapType.Minimum ? comparer : new ReverseComparer<T>(comparer);
_comparerToUse = type == HeapType.Minimum ? comparer : new ReverseComparer<T>(comparer);
}
#endregion
@ -136,7 +139,7 @@ namespace NGenerics.DataStructures.General
#region Public Members
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="Root" lang="cs" title="The following example shows how to use the Root property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="Root" lang="vbnet" title="The following example shows how to use the Root property."/>
@ -154,12 +157,12 @@ namespace NGenerics.DataStructures.General
#endregion
return data[1];
return _data[1];
}
}
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="RemoveRoot" lang="cs" title="The following example shows how to use the RemoveRoot method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="RemoveRoot" lang="vbnet" title="The following example shows how to use the RemoveRoot method."/>
@ -176,9 +179,9 @@ namespace NGenerics.DataStructures.General
#endregion
// The minimum item to return.
var minimum = data[1];
var minimum = _data[1];
RemoveRootItem(minimum);
RemoveRootItem(minimum);
return minimum;
}
@ -193,10 +196,9 @@ namespace NGenerics.DataStructures.General
/// </remarks>
protected virtual void RemoveRootItem(T item)
{
// The last item in the heap
var last = data[Count];
data.RemoveAt(Count);
var last = _data[Count];
_data.RemoveAt(Count);
// If there's still items left in this heap, re-heapify it.
if (Count > 0)
@ -204,28 +206,27 @@ namespace NGenerics.DataStructures.General
// Re-heapify the binary tree to conform to the heap property
var counter = 1;
while ((counter * 2) < (data.Count))
while ((counter * 2) < (_data.Count))
{
var child = counter * 2;
if (((child + 1) < (data.Count)) &&
(comparerToUse.Compare(data[child + 1], data[child]) < 0))
if (((child + 1) < (_data.Count)) &&
(_comparerToUse.Compare(_data[child + 1], _data[child]) < 0))
{
child++;
}
if (comparerToUse.Compare(last, data[child]) <= 0)
if (_comparerToUse.Compare(last, _data[child]) <= 0)
{
break;
}
data[counter] = data[child];
_data[counter] = _data[child];
counter = child;
}
data[counter] = last;
_data[counter] = last;
}
}
@ -242,7 +243,7 @@ namespace NGenerics.DataStructures.General
{
get
{
return thisType;
return _thisType;
}
}
@ -250,9 +251,9 @@ namespace NGenerics.DataStructures.General
#region ICollection<T> Members
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="IsEmpty" lang="cs" title="The following example shows how to use the IsEmpty property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="IsEmpty" lang="vbnet" title="The following example shows how to use the IsEmpty property."/>
@ -265,19 +266,19 @@ namespace NGenerics.DataStructures.General
}
}
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="Contains" lang="cs" title="The following example shows how to use the Contains method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="Contains" lang="vbnet" title="The following example shows how to use the Contains method."/>
/// </example>
public bool Contains(T item)
{
return data.Contains(item);
return _data.Contains(item);
}
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="CopyTo" lang="cs" title="The following example shows how to use the CopyTo method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="CopyTo" lang="vbnet" title="The following example shows how to use the CopyTo method."/>
@ -295,13 +296,13 @@ namespace NGenerics.DataStructures.General
#endregion
for (var i = 1; i < data.Count; i++)
for (var i = 1; i < _data.Count; i++)
{
array[arrayIndex++] = data[i];
array[arrayIndex++] = _data[i];
}
}
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="Count" lang="cs" title="The following example shows how to use the Count property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="Count" lang="vbnet" title="The following example shows how to use the Count property."/>
@ -310,18 +311,18 @@ namespace NGenerics.DataStructures.General
{
get
{
return data.Count - 1;
return _data.Count - 1;
}
}
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="Add" lang="cs" title="The following example shows how to use the Add method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="Add" lang="vbnet" title="The following example shows how to use the Add method."/>
/// </example>
public void Add(T item)
{
AddItem(item);
AddItem(item);
}
/// <summary>
@ -333,24 +334,24 @@ namespace NGenerics.DataStructures.General
/// Derived classes can override this method to change the behavior of the <see cref="Add"/> method.
/// </remarks>
protected virtual void AddItem(T item)
{
// Add a dummy to the end of the list (it will be replaced)
data.Add(default(T));
{
// Add a dummy to the end of the list (it will be replaced)
_data.Add(default(T));
var counter = data.Count - 1;
var counter = _data.Count - 1;
while ((counter > 1) && (_comparerToUse.Compare(_data[counter / 2], item) > 0))
{
_data[counter] = _data[counter / 2];
counter = counter / 2;
}
while ((counter > 1) && (comparerToUse.Compare(data[counter / 2], item) > 0))
{
data[counter] = data[counter / 2];
counter = counter / 2;
}
_data[counter] = item;
}
data[counter] = item;
}
/// <inheritdoc />
/// <inheritdoc />
/// <exception cref="NotSupportedException">Always.</exception>
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
bool ICollection<T>.Remove(T item)
@ -370,38 +371,38 @@ namespace NGenerics.DataStructures.General
/// </example>
public IEnumerator<T> GetEnumerator()
{
for (var i = 1; i < data.Count; i++)
for (var i = 1; i < _data.Count; i++)
{
yield return data[i];
yield return _data[i];
}
}
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="Clear" lang="cs" title="The following example shows how to use the Clear method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="Clear" lang="vbnet" title="The following example shows how to use the Clear method."/>
/// </example>
public void Clear()
{
ClearItems();
ClearItems();
}
/// <summary>
/// Clears all the objects in this instance.
/// </summary>
/// <remarks>
/// <b>Notes to Inheritors: </b>
/// Derived classes can override this method to change the behavior of the <see cref="Clear"/> method.
/// </remarks>
protected virtual void ClearItems()
{
_data.RemoveRange(1, _data.Count - 1); // Clears all objects in this instance except the first dummy one.
}
/// <summary>
/// Clears all the objects in this instance.
/// </summary>
/// <remarks>
/// <b>Notes to Inheritors: </b>
/// Derived classes can override this method to change the behavior of the <see cref="Clear"/> method.
/// </remarks>
protected virtual void ClearItems()
{
data.RemoveRange(1, data.Count - 1); // Clears all objects in this instance except the first dummy one.
}
#endregion
#region ICollection<T> Members
/// <inheritdoc />
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\HeapExamples.cs" region="IsReadOnly" lang="cs" title="The following example shows how to use the IsReadOnly property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\HeapExamples.vb" region="IsReadOnly" lang="vbnet" title="The following example shows how to use the IsReadOnly property."/>
@ -418,7 +419,7 @@ namespace NGenerics.DataStructures.General
#region IEnumerable Members
/// <inheritdoc />
/// <inheritdoc />
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();

3
src/NGenerics/DataStructures/General/HeapType.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)

53
src/NGenerics/DataStructures/General/IHeap.cs

@ -1,4 +1,7 @@
/*
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -12,30 +15,30 @@ using System;
namespace NGenerics.DataStructures.General
{
/// <summary>
/// An interface for the <see cref="Heap{T}"/> data structure.
/// </summary>
/// <typeparam name="T">The type of elements in the heap.</typeparam>
public interface IHeap<T>
{
/// <summary>
/// Adds the specified item.
/// </summary>
/// <param name="item">The item.</param>
void Add(T item);
/// <summary>
/// An interface for the <see cref="Heap{T}"/> data structure.
/// </summary>
/// <typeparam name="T">The type of elements in the heap.</typeparam>
public interface IHeap<T>
{
/// <summary>
/// Adds the specified item.
/// </summary>
/// <param name="item">The item.</param>
void Add(T item);
/// <summary>
/// Removes the root and returns it.
/// </summary>
/// <returns>The root of the <see cref="Heap{T}"/>.</returns>
/// <exception cref="InvalidOperationException">The <see cref="Graph{T}"/> is empty.</exception>
T RemoveRoot();
/// <summary>
/// Removes the root and returns it.
/// </summary>
/// <returns>The root of the <see cref="Heap{T}"/>.</returns>
/// <exception cref="InvalidOperationException">The <see cref="Graph{T}"/> is empty.</exception>
T RemoveRoot();
/// <summary>
/// Gets the root.
/// </summary>
/// <value>The root.</value>
/// <exception cref="InvalidOperationException">The <see cref="Heap{T}"/> is empty.</exception>
T Root { get; }
}
/// <summary>
/// Gets the root.
/// </summary>
/// <value>The root.</value>
/// <exception cref="InvalidOperationException">The <see cref="Heap{T}"/> is empty.</exception>
T Root { get; }
}
}

41
src/NGenerics/DataStructures/Queues/IQueue.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -19,25 +22,25 @@ namespace NGenerics.DataStructures.Queues
/// <typeparam name="T">The type of the elements in the queue.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public interface IQueue<T>
{
/// <summary>
/// Enqueues the item at the back of the queue.
/// </summary>
/// <param name="item">The item.</param>
void Enqueue(T item);
{
/// <summary>
/// Enqueues the item at the back of the queue.
/// </summary>
/// <param name="item">The item.</param>
void Enqueue(T item);
/// <summary>
/// Dequeues the item at the front of the queue.
/// </summary>
/// <returns>The item at the front of the queue.</returns>
/// <exception cref="InvalidOperationException">The <see cref="Deque{T}"/> is empty.</exception>
T Dequeue();
/// <summary>
/// Dequeues the item at the front of the queue.
/// </summary>
/// <returns>The item at the front of the queue.</returns>
/// <exception cref="InvalidOperationException">The <see cref="Deque{T}"/> is empty.</exception>
T Dequeue();
/// <summary>
/// Peeks at the item in the front of the queue, without removing it.
/// </summary>
/// <returns>The item at the front of the queue.</returns>
/// <exception cref="InvalidOperationException">The <see cref="Deque{T}"/> is empty.</exception>
T Peek();
}
/// <summary>
/// Peeks at the item in the front of the queue, without removing it.
/// </summary>
/// <returns>The item at the front of the queue.</returns>
/// <exception cref="InvalidOperationException">The <see cref="Deque{T}"/> is empty.</exception>
T Peek();
}
}

107
src/NGenerics/DataStructures/Queues/PriorityQueue.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -27,15 +30,15 @@ namespace NGenerics.DataStructures.Queues
/// <typeparam name="TPriority">The type of the priority in the <see cref="PriorityQueue{TPriority, TValue}"/>.</typeparam>
/// <typeparam name="TValue">The type of the elements in the <see cref="PriorityQueue{TPriority, TValue}"/>.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
//[Serializable]
public class PriorityQueue<TValue, TPriority> : ICollection<TValue>, IQueue<TValue>
public class PriorityQueue<TValue, TPriority> : ICollection<TValue>, IQueue<TValue>
{
#region Globals
private readonly RedBlackTreeList<TPriority, TValue> tree;
private TPriority defaultPriority;
private readonly PriorityQueueType queueType;
private readonly RedBlackTreeList<TPriority, TValue> _tree;
private TPriority _defaultPriority;
private readonly PriorityQueueType _queueType;
#endregion
@ -47,17 +50,19 @@ namespace NGenerics.DataStructures.Queues
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Queues\PriorityQueueExamples.vb" region="Constructor" lang="vbnet" title="The following example shows how to use the default constructor."/>
/// </example>
public PriorityQueue(PriorityQueueType queueType) :
this(queueType, Comparer<TPriority>.Default) {
this(queueType, Comparer<TPriority>.Default)
{
}
/// <inheritdoc/>
public PriorityQueue(PriorityQueueType queueType, IComparer<TPriority> comparer) {
if ((queueType != PriorityQueueType.Minimum) && (queueType != PriorityQueueType.Maximum)) {
public PriorityQueue(PriorityQueueType queueType, IComparer<TPriority> comparer)
{
if ((queueType != PriorityQueueType.Minimum) && (queueType != PriorityQueueType.Maximum))
{
throw new ArgumentOutOfRangeException("queueType");
}
this.queueType = queueType;
tree = new RedBlackTreeList<TPriority, TValue>(comparer);
_queueType = queueType;
_tree = new RedBlackTreeList<TPriority, TValue>(comparer);
}
/// <summary>
@ -67,8 +72,8 @@ namespace NGenerics.DataStructures.Queues
/// <param name="comparison">The comparison.</param>
/// <inheritdoc/>
public PriorityQueue(PriorityQueueType queueType, Comparison<TPriority> comparison) :
this(queueType, new ComparisonComparer<TPriority>(comparison)) {
this(queueType, new ComparisonComparer<TPriority>(comparison))
{
}
#endregion
@ -187,7 +192,7 @@ namespace NGenerics.DataStructures.Queues
/// </example>
public IEnumerator<TValue> GetEnumerator()
{
return tree.GetValueEnumerator();
return _tree.GetValueEnumerator();
}
#endregion
@ -208,7 +213,7 @@ namespace NGenerics.DataStructures.Queues
/// </example>
public bool Contains(TValue item)
{
return tree.ContainsValue(item);
return _tree.ContainsValue(item);
}
/// <inheritdoc />
@ -230,7 +235,7 @@ namespace NGenerics.DataStructures.Queues
#endregion
foreach (var association in tree)
foreach (var association in _tree)
{
var items = association.Value;
@ -248,7 +253,7 @@ namespace NGenerics.DataStructures.Queues
/// </example>
public void Add(TValue item)
{
Add(item, defaultPriority);
Add(item, _defaultPriority);
}
/// <summary>
@ -285,7 +290,7 @@ namespace NGenerics.DataStructures.Queues
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public IEnumerator<KeyValuePair<TPriority, TValue>> GetKeyEnumerator()
{
return tree.GetKeyEnumerator();
return _tree.GetKeyEnumerator();
}
/// <inheritdoc />
@ -334,7 +339,7 @@ namespace NGenerics.DataStructures.Queues
if (association.Value.Count == 0)
{
tree.Remove(association.Key);
_tree.Remove(association.Key);
}
Count--;
@ -351,11 +356,11 @@ namespace NGenerics.DataStructures.Queues
{
get
{
return defaultPriority;
return _defaultPriority;
}
set
{
defaultPriority = value;
_defaultPriority = value;
}
}
@ -369,7 +374,7 @@ namespace NGenerics.DataStructures.Queues
public bool Remove(TValue item, out TPriority priority)
{
return RemoveItem(item, out priority);
}
}
/// <summary>
/// Removes the item.
/// </summary>
@ -383,7 +388,7 @@ namespace NGenerics.DataStructures.Queues
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#")]
protected virtual bool RemoveItem(TValue item, out TPriority priority)
{
var removed = tree.Remove(item, out priority);
var removed = _tree.Remove(item, out priority);
if (removed)
{
@ -392,7 +397,7 @@ namespace NGenerics.DataStructures.Queues
return removed;
}
/// <summary>
/// Removes the items with the specified priority.
/// </summary>
@ -400,8 +405,8 @@ namespace NGenerics.DataStructures.Queues
/// <returns><c>true</c> if the priority exists in the <see cref="PriorityQueue{TValue, TPriority}"/> and has been removed; otherwise <c>false</c>.</returns>
public bool RemovePriorityGroup(TPriority priority)
{
return RemoveItems(priority);
}
return RemoveItems(priority);
}
/// <summary>
/// Removes the items from the collection with the specified priority.
@ -409,30 +414,30 @@ namespace NGenerics.DataStructures.Queues
/// <param name="priority">The priority to search for.</param>
/// <returns>An indication of whether items were found having the specified priority.</returns>
protected virtual bool RemoveItems(TPriority priority)
{
LinkedList<TValue> items;
if (tree.TryGetValue(priority, out items))
{
tree.Remove(priority);
Count -= items.Count;
return true;
}
return false;
}
/// <summary>
{
LinkedList<TValue> items;
if (_tree.TryGetValue(priority, out items))
{
_tree.Remove(priority);
Count -= items.Count;
return true;
}
return false;
}
/// <summary>
/// Removes the items with the specified priority.
/// </summary>
/// <param name="priority">The priority.</param>
/// <returns>The items with the specified priority.</returns>
public IList<TValue> GetPriorityGroup(TPriority priority)
{
LinkedList<TValue> items;
{
LinkedList<TValue> items;
return tree.TryGetValue(priority, out items) ? new List<TValue>(items) : new List<TValue>();
}
return _tree.TryGetValue(priority, out items) ? new List<TValue>(items) : new List<TValue>();
}
/// <summary>
@ -465,7 +470,7 @@ namespace NGenerics.DataStructures.Queues
{
LinkedList<TValue> currentValues;
if (tree.TryGetValue(priority, out currentValues))
if (_tree.TryGetValue(priority, out currentValues))
{
for (var i = 0; i < items.Count; i++)
{
@ -475,7 +480,7 @@ namespace NGenerics.DataStructures.Queues
else
{
currentValues = new LinkedList<TValue>(items);
tree.Add(priority, currentValues);
_tree.Add(priority, currentValues);
}
}
@ -496,7 +501,7 @@ namespace NGenerics.DataStructures.Queues
{
LinkedList<TValue> list;
if (tree.TryGetValue(priority, out list))
if (_tree.TryGetValue(priority, out list))
{
list.AddLast(item);
}
@ -504,7 +509,7 @@ namespace NGenerics.DataStructures.Queues
{
list = new LinkedList<TValue>();
list.AddLast(item);
tree.Add(priority, list);
_tree.Add(priority, list);
}
Count++;
@ -519,7 +524,7 @@ namespace NGenerics.DataStructures.Queues
/// </remarks>
protected virtual void ClearItems()
{
tree.Clear();
_tree.Clear();
Count = 0;
}
@ -532,7 +537,7 @@ namespace NGenerics.DataStructures.Queues
/// </summary>
private void CheckTreeNotEmpty()
{
if (tree.Count == 0)
if (_tree.Count == 0)
{
throw new InvalidOperationException("The Priority Queue is empty.");
}
@ -549,7 +554,7 @@ namespace NGenerics.DataStructures.Queues
#endregion
return queueType == PriorityQueueType.Maximum ? tree.Maximum : tree.Minimum;
return _queueType == PriorityQueueType.Maximum ? _tree.Maximum : _tree.Minimum;
}
#endregion

3
src/NGenerics/DataStructures/Queues/PriorityQueueType.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)

62
src/NGenerics/DataStructures/Trees/BinarySearchTreeBase.cs

@ -1,4 +1,7 @@
/*
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -18,7 +21,6 @@ using NGenerics.Util;
namespace NGenerics.DataStructures.Trees
{
/// <summary>
/// A base class for Binary Search Trees that store a single value in each node.
/// </summary>
@ -26,12 +28,11 @@ namespace NGenerics.DataStructures.Trees
//[Serializable]
public abstract class BinarySearchTreeBase<T> : ISearchTree<T>
{
#region Globals
internal const string alreadyContainedInTheTree = "The item is already contained in the tree.";
private BinaryTree<T> tree;
private readonly IComparer<T> comparer;
private BinaryTree<T> _tree;
private readonly IComparer<T> _comparer;
#endregion
@ -52,7 +53,7 @@ namespace NGenerics.DataStructures.Trees
/// </summary>
protected BinarySearchTreeBase()
{
comparer = Comparer<T>.Default;
_comparer = Comparer<T>.Default;
}
/// <summary>
@ -63,7 +64,7 @@ namespace NGenerics.DataStructures.Trees
protected BinarySearchTreeBase(IComparer<T> comparer)
{
Guard.ArgumentNotNull(comparer, "comparer");
this.comparer = comparer;
_comparer = comparer;
}
/// <summary>
@ -73,7 +74,7 @@ namespace NGenerics.DataStructures.Trees
protected BinarySearchTreeBase(Comparison<T> comparison)
{
Guard.ArgumentNotNull(comparison, "comparison");
comparer = new ComparisonComparer<T>(comparison);
_comparer = new ComparisonComparer<T>(comparison);
}
#endregion
@ -88,7 +89,7 @@ namespace NGenerics.DataStructures.Trees
{
get
{
return comparer;
return _comparer;
}
}
@ -106,16 +107,16 @@ namespace NGenerics.DataStructures.Trees
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
protected virtual BinaryTree<T> FindNode(T item)
{
if (tree == null)
if (_tree == null)
{
return null;
}
var currentNode = tree;
var currentNode = _tree;
while (currentNode != null)
{
var nodeResult = comparer.Compare(item, currentNode.Data);
var nodeResult = _comparer.Compare(item, currentNode.Data);
if (nodeResult == 0)
{
@ -137,12 +138,12 @@ namespace NGenerics.DataStructures.Trees
/// <returns>The item if found, else null.</returns>
protected virtual BinaryTree<T> FindNode<TSearch>(TSearch value, CustomComparison<TSearch> customComparison)
{
if (tree == null)
if (_tree == null)
{
return null;
}
var currentNode = tree;
var currentNode = _tree;
while (currentNode != null)
{
@ -182,11 +183,11 @@ namespace NGenerics.DataStructures.Trees
{
#region Debug
Debug.Assert(tree != null);
Debug.Assert(_tree != null);
#endregion
return FindMaximumNode(tree);
return FindMaximumNode(_tree);
}
@ -199,11 +200,11 @@ namespace NGenerics.DataStructures.Trees
{
#region Debug
Debug.Assert(tree != null);
Debug.Assert(_tree != null);
#endregion
return FindMinimumNode(tree);
return FindMinimumNode(_tree);
}
/// <summary>
@ -264,11 +265,11 @@ namespace NGenerics.DataStructures.Trees
{
get
{
return tree;
return _tree;
}
set
{
tree = value;
_tree = value;
}
}
@ -343,18 +344,13 @@ namespace NGenerics.DataStructures.Trees
return FindMaximumNode().Data;
}
}
/// <inheritdoc/>
} /// <inheritdoc/>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public void DepthFirstTraversal(OrderedVisitor<T> visitor)
{
Guard.ArgumentNotNull(visitor, "visitor");
VisitNode(tree, visitor);
VisitNode(_tree, visitor);
}
/// <inheritdoc/>
@ -362,12 +358,12 @@ namespace NGenerics.DataStructures.Trees
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public IEnumerator<T> GetOrderedEnumerator()
{
if (tree != null)
if (_tree != null)
{
var trackingVisitor = new TrackingVisitor<T>();
var inOrderVisitor = new InOrderVisitor<T>(trackingVisitor);
tree.DepthFirstTraversal(inOrderVisitor);
_tree.DepthFirstTraversal(inOrderVisitor);
var trackingList = trackingVisitor.TrackingList;
@ -423,7 +419,7 @@ namespace NGenerics.DataStructures.Trees
/// </remarks>
protected virtual void ClearItems()
{
tree = null;
_tree = null;
Count = 0;
}
@ -457,11 +453,11 @@ namespace NGenerics.DataStructures.Trees
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public IEnumerator<T> GetEnumerator()
{
if (tree != null)
if (_tree != null)
{
var stack = new Stack<BinaryTree<T>>();
stack.Push(tree);
stack.Push(_tree);
while (stack.Count > 0)
{
@ -528,7 +524,7 @@ namespace NGenerics.DataStructures.Trees
#endregion
foreach (var association in tree)
foreach (var association in _tree)
{
array[arrayIndex++] = association;
}

252
src/NGenerics/DataStructures/Trees/BinaryTree.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -27,72 +30,72 @@ namespace NGenerics.DataStructures.Trees
{
#region Globals
private BinaryTree<T> leftSubtree;
private BinaryTree<T> rightSubtree;
private T data;
private BinaryTree<T> _leftSubtree;
private BinaryTree<T> _rightSubtree;
private T _data;
#endregion
#endregion
#region Construction
#region Construction
/// <param name="data">The data contained in this node.</param>
public BinaryTree(T data) : this(data, null, null) { }
/// <param name="data">The data contained in this node.</param>
public BinaryTree(T data) : this(data, null, null) { }
/// <param name="data">The data.</param>
/// <param name="left">The data of the left subtree.</param>
/// <param name="right">The data of the right subtree.</param>
public BinaryTree(T data, T left, T right) : this(data, new BinaryTree<T>(left), new BinaryTree<T>(right)) { }
/// <param name="data">The data.</param>
/// <param name="left">The data of the left subtree.</param>
/// <param name="right">The data of the right subtree.</param>
public BinaryTree(T data, T left, T right) : this(data, new BinaryTree<T>(left), new BinaryTree<T>(right)) { }
/// <param name="data">The data contained in this node.</param>
/// <param name="left">The left subtree.</param>
/// <param name="right">The right subtree.</param>
public BinaryTree(T data, BinaryTree<T> left, BinaryTree<T> right)
: this(data, left, right, true)
{
}
/// <param name="data">The data contained in this node.</param>
/// <param name="left">The left subtree.</param>
/// <param name="right">The right subtree.</param>
public BinaryTree(T data, BinaryTree<T> left, BinaryTree<T> right)
: this(data, left, right, true)
{
}
/// <param name="data">The data contained in this node.</param>
/// <param name="left">The left subtree.</param>
/// <param name="right">The right subtree.</param>
/// <param name="validateData"><see langword="true"/> to validate <paramref name="data"/>; otherwise <see langword="false"/>.</param>
internal BinaryTree(T data, BinaryTree<T> left, BinaryTree<T> right, bool validateData)
{
#region Validation
/// <param name="data">The data contained in this node.</param>
/// <param name="left">The left subtree.</param>
/// <param name="right">The right subtree.</param>
/// <param name="validateData"><see langword="true"/> to validate <paramref name="data"/>; otherwise <see langword="false"/>.</param>
internal BinaryTree(T data, BinaryTree<T> left, BinaryTree<T> right, bool validateData)
{
#region Validation
//TODO: probably not the most efficient way of doing this but SplayTree needs to use a BinaryTree with null data.
if (validateData)
{
Guard.ArgumentNotNull(data, "data");
}
//TODO: probably not the most efficient way of doing this but SplayTree needs to use a BinaryTree with null data.
if (validateData)
{
Guard.ArgumentNotNull(data, "data");
}
#endregion
#endregion
leftSubtree = left;
_leftSubtree = left;
if (left != null)
{
left.Parent = this;
}
if (left != null)
{
left.Parent = this;
}
rightSubtree = right;
_rightSubtree = right;
if (right != null)
{
right.Parent = this;
}
if (right != null)
{
right.Parent = this;
}
this.data = data;
}
_data = data;
}
#endregion
#endregion
#region ICollection<T> Members
/// <inheritdoc />
/// <inheritdoc />
public bool IsEmpty
{
get
@ -101,16 +104,16 @@ namespace NGenerics.DataStructures.Trees
}
}
/// <inheritdoc />
/// <inheritdoc />
public bool IsFull
{
get
{
return (leftSubtree != null) && (rightSubtree != null);
return (_leftSubtree != null) && (_rightSubtree != null);
}
}
/// <inheritdoc />
/// <inheritdoc />
public bool Contains(T item)
{
foreach (var thisItem in this)
@ -124,7 +127,7 @@ namespace NGenerics.DataStructures.Trees
return false;
}
/// <inheritdoc />
/// <inheritdoc />
public void CopyTo(T[] array, int arrayIndex)
{
Guard.ArgumentNotNull(array, "array");
@ -144,19 +147,19 @@ namespace NGenerics.DataStructures.Trees
}
}
/// <inheritdoc />
/// <inheritdoc />
public int Count
{
get
{
var count = 0;
if (leftSubtree != null)
if (_leftSubtree != null)
{
count++;
}
if (rightSubtree != null)
if (_rightSubtree != null)
{
count++;
}
@ -165,27 +168,27 @@ namespace NGenerics.DataStructures.Trees
}
}
/// <inheritdoc />
/// <inheritdoc />
public void Add(T item)
{
AddItem(new BinaryTree<T>(item));
}
/// <inheritdoc />
/// <inheritdoc />
public bool Remove(T item)
{
if (leftSubtree != null)
if (_leftSubtree != null)
{
if (leftSubtree.data.Equals(item))
if (_leftSubtree._data.Equals(item))
{
RemoveLeft();
return true;
}
}
if (rightSubtree != null)
if (_rightSubtree != null)
{
if (rightSubtree.data.Equals(item))
if (_rightSubtree._data.Equals(item))
{
RemoveRight();
return true;
@ -202,18 +205,18 @@ namespace NGenerics.DataStructures.Trees
/// <returns>A value indicating whether the child was found (and removed) from this tree.</returns>
public bool Remove(BinaryTree<T> child)
{
if (leftSubtree != null)
if (_leftSubtree != null)
{
if (leftSubtree == child)
if (_leftSubtree == child)
{
RemoveLeft();
return true;
}
}
if (rightSubtree != null)
if (_rightSubtree != null)
{
if (rightSubtree == child)
if (_rightSubtree == child)
{
RemoveRight();
return true;
@ -241,31 +244,31 @@ namespace NGenerics.DataStructures.Trees
yield return tree.Data;
if (tree.leftSubtree != null)
if (tree._leftSubtree != null)
{
stack.Push(tree.leftSubtree);
stack.Push(tree._leftSubtree);
}
if (tree.rightSubtree != null)
if (tree._rightSubtree != null)
{
stack.Push(tree.rightSubtree);
stack.Push(tree._rightSubtree);
}
}
}
/// <inheritdoc />
/// <inheritdoc />
public virtual void Clear()
{
if (leftSubtree != null)
if (_leftSubtree != null)
{
leftSubtree.Parent = null;
leftSubtree = null;
_leftSubtree.Parent = null;
_leftSubtree = null;
}
if (rightSubtree != null)
if (_rightSubtree != null)
{
rightSubtree.Parent = null;
rightSubtree = null;
_rightSubtree.Parent = null;
_rightSubtree = null;
}
}
@ -273,31 +276,31 @@ namespace NGenerics.DataStructures.Trees
#region ITree<T> Members
/// <inheritdoc />
/// <inheritdoc />
void ITree<T>.Add(ITree<T> child)
{
AddItem((BinaryTree<T>)child);
}
/// <inheritdoc />
/// <inheritdoc />
ITree<T> ITree<T>.GetChild(int index)
{
return GetChild(index);
}
/// <inheritdoc />
/// <inheritdoc />
bool ITree<T>.Remove(ITree<T> child)
{
return Remove((BinaryTree<T>)child);
}
/// <inheritdoc />
/// <inheritdoc />
ITree<T> ITree<T>.FindNode(Predicate<T> condition)
{
return FindNode(condition);
}
/// <inheritdoc />
/// <inheritdoc />
ITree<T> ITree<T>.Parent
{
get
@ -331,10 +334,10 @@ namespace NGenerics.DataStructures.Trees
{
return this;
}
if (leftSubtree != null)
if (_leftSubtree != null)
{
var ret = leftSubtree.FindNode(condition);
var ret = _leftSubtree.FindNode(condition);
if (ret != null)
{
@ -342,9 +345,9 @@ namespace NGenerics.DataStructures.Trees
}
}
if (rightSubtree != null)
if (_rightSubtree != null)
{
var ret = rightSubtree.FindNode(condition);
var ret = _rightSubtree.FindNode(condition);
if (ret != null)
{
@ -364,11 +367,11 @@ namespace NGenerics.DataStructures.Trees
{
get
{
return leftSubtree;
return _leftSubtree;
}
set
{
if (leftSubtree != null)
if (_leftSubtree != null)
{
RemoveLeft();
}
@ -383,7 +386,7 @@ namespace NGenerics.DataStructures.Trees
value.Parent = this;
}
leftSubtree = value;
_leftSubtree = value;
}
}
@ -396,12 +399,11 @@ namespace NGenerics.DataStructures.Trees
{
get
{
return rightSubtree;
return _rightSubtree;
}
set
{
if (rightSubtree != null)
if (_rightSubtree != null)
{
RemoveRight();
}
@ -416,16 +418,16 @@ namespace NGenerics.DataStructures.Trees
value.Parent = this;
}
rightSubtree = value;
_rightSubtree = value;
}
}
/// <inheritdoc />
/// <inheritdoc />
public virtual T Data
{
get
{
return data;
return _data;
}
set
{
@ -435,11 +437,11 @@ namespace NGenerics.DataStructures.Trees
#endregion
data = value;
_data = value;
}
}
/// <inheritdoc />
/// <inheritdoc />
public int Degree
{
get
@ -459,14 +461,14 @@ namespace NGenerics.DataStructures.Trees
switch (index)
{
case 0:
return leftSubtree;
return _leftSubtree;
case 1:
return rightSubtree;
return _rightSubtree;
default:
throw new ArgumentOutOfRangeException("index");
}
}
/// <inheritdoc />
/// <inheritdoc />
public virtual int Height
{
get
@ -475,7 +477,7 @@ namespace NGenerics.DataStructures.Trees
{
return 0;
}
return 1 + FindMaximumChildHeight();
}
}
@ -494,21 +496,21 @@ namespace NGenerics.DataStructures.Trees
{
return;
}
// Preorder visit
orderedVisitor.VisitPreOrder(Data);
if (leftSubtree != null)
if (_leftSubtree != null)
{
leftSubtree.DepthFirstTraversal(orderedVisitor);
_leftSubtree.DepthFirstTraversal(orderedVisitor);
}
// In-order visit
orderedVisitor.VisitInOrder(data);
orderedVisitor.VisitInOrder(_data);
if (rightSubtree != null)
if (_rightSubtree != null)
{
rightSubtree.DepthFirstTraversal(orderedVisitor);
_rightSubtree.DepthFirstTraversal(orderedVisitor);
}
// PostOrder visit
@ -551,7 +553,7 @@ namespace NGenerics.DataStructures.Trees
}
/// <inheritdoc />
/// <inheritdoc />
public virtual bool IsLeafNode
{
get
@ -565,10 +567,10 @@ namespace NGenerics.DataStructures.Trees
/// </summary>
public virtual void RemoveLeft()
{
if (leftSubtree != null)
if (_leftSubtree != null)
{
leftSubtree.Parent = null;
leftSubtree = null;
_leftSubtree.Parent = null;
_leftSubtree = null;
}
}
@ -577,10 +579,10 @@ namespace NGenerics.DataStructures.Trees
/// </summary>
public virtual void RemoveRight()
{
if (rightSubtree != null)
if (_rightSubtree != null)
{
rightSubtree.Parent = null;
rightSubtree = null;
_rightSubtree.Parent = null;
_rightSubtree = null;
}
}
@ -595,8 +597,8 @@ namespace NGenerics.DataStructures.Trees
{
Guard.ArgumentNotNull(subtree, "subtree");
AddItem(subtree);
}
AddItem(subtree);
}
/// <summary>
/// Adds an item to the <see cref="ICollection{T}"/>.
@ -608,24 +610,24 @@ namespace NGenerics.DataStructures.Trees
/// </remarks>
protected virtual void AddItem(BinaryTree<T> subtree)
{
if (leftSubtree == null)
if (_leftSubtree == null)
{
if (subtree.Parent != null)
{
subtree.Parent.Remove(subtree);
}
leftSubtree = subtree;
_leftSubtree = subtree;
subtree.Parent = this;
}
else if (rightSubtree == null)
else if (_rightSubtree == null)
{
if (subtree.Parent != null)
{
subtree.Parent.Remove(subtree);
}
rightSubtree = subtree;
_rightSubtree = subtree;
subtree.Parent = this;
}
else
@ -648,14 +650,14 @@ namespace NGenerics.DataStructures.Trees
var leftHeight = 0;
var rightHeight = 0;
if (leftSubtree != null)
if (_leftSubtree != null)
{
leftHeight = leftSubtree.Height;
leftHeight = _leftSubtree.Height;
}
if (rightSubtree != null)
if (_rightSubtree != null)
{
rightHeight = rightSubtree.Height;
rightHeight = _rightSubtree.Height;
}
return leftHeight > rightHeight ? leftHeight : rightHeight;
@ -680,7 +682,7 @@ namespace NGenerics.DataStructures.Trees
#region ICollection<T> Members
/// <inheritdoc />
/// <inheritdoc />
public bool IsReadOnly
{
get
@ -693,7 +695,7 @@ namespace NGenerics.DataStructures.Trees
#region IEnumerable Members
/// <inheritdoc />
/// <inheritdoc />
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
@ -703,10 +705,10 @@ namespace NGenerics.DataStructures.Trees
#region Object Members
/// <inheritdoc />
/// <inheritdoc />
public override string ToString()
{
return data.ToString();
return _data.ToString();
}
#endregion

9
src/NGenerics/DataStructures/Trees/ISearchTree.cs

@ -1,4 +1,7 @@
/*
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -15,13 +18,13 @@ using NGenerics.Patterns.Visitor;
namespace NGenerics.DataStructures.Trees
{
/// <summary>
/// An interface for Search Trees that mimic a dictionary.
/// </summary>
/// <typeparam name="T">The type of element to hold in the tree.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public interface ISearchTree<T> : ICollection<T> {
public interface ISearchTree<T> : ICollection<T>
{
/// <summary>
/// Gets the largest item in the tree.
/// </summary>

13
src/NGenerics/DataStructures/Trees/ITree.cs

@ -1,4 +1,7 @@
/*
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -9,12 +12,14 @@
using System;
namespace NGenerics.DataStructures.Trees {
namespace NGenerics.DataStructures.Trees
{
/// <summary>
/// An interface for the tree data structure
/// </summary>
/// <typeparam name="T">The type of elements in the tree.</typeparam>
public interface ITree<T> {
public interface ITree<T>
{
/// <summary>
/// Adds the specified child to the tree.
/// </summary>
@ -72,6 +77,6 @@ namespace NGenerics.DataStructures.Trees {
/// Gets the parent of the current node.
/// </summary>
/// <value>The parent of the current node.</value>
ITree<T> Parent { get;}
ITree<T> Parent { get; }
}
}

3
src/NGenerics/DataStructures/Trees/NodeColor.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)

120
src/NGenerics/DataStructures/Trees/RedBlackTree.cs

@ -1,4 +1,7 @@
/*
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -17,32 +20,36 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace NGenerics.DataStructures.Trees {
namespace NGenerics.DataStructures.Trees
{
/// <summary>
/// An implementation of a Red-Black tree.
/// </summary>
/// <typeparam name="T">The type of element to keep in the tree.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
//[Serializable]
public class RedBlackTree<T> : BinarySearchTreeBase<T> {
public class RedBlackTree<T> : BinarySearchTreeBase<T>
{
#region Construction
/// <inheritdoc />
public RedBlackTree() {
public RedBlackTree()
{
// Do nothing - the default Comparer will be used by the base class.
}
/// <inheritdoc/>
public RedBlackTree(IComparer<T> comparer)
: base(comparer) {
: base(comparer)
{
// Do nothing else.
}
/// <inheritdoc/>
public RedBlackTree(Comparison<T> comparison)
: base(comparison) {
: base(comparison)
{
// Do nothing else.
}
@ -54,10 +61,12 @@ namespace NGenerics.DataStructures.Trees {
/// Adds an element with the provided key and value to the <see cref="IDictionary{TKey,TValue}"/>.
/// </summary>
/// <param name="item">The item.</param>
protected override void AddItem(T item) {
protected override void AddItem(T item)
{
#region Validation
if (Equals(item, null)) {
if (Equals(item, null))
{
throw new ArgumentNullException("item");
}
@ -78,8 +87,10 @@ namespace NGenerics.DataStructures.Trees {
/// <c>true</c> if the element is successfully removed; otherwise, <c>false</c>. This method also returns false if key was not found in the original <see cref="IDictionary{TKey,TValue}"/>.
/// </returns>
/// <inheritdoc/>
protected override bool RemoveItem(T item) {
if (Tree != null) {
protected override bool RemoveItem(T item)
{
if (Tree != null)
{
var startNode = new RedBlackTreeNode<T>(default(T));
var childNode = startNode;
@ -90,7 +101,8 @@ namespace NGenerics.DataStructures.Trees {
var direction = true;
while (childNode[direction] != null) {
while (childNode[direction] != null)
{
var lastDirection = direction;
var grandParent = parent;
@ -99,29 +111,41 @@ namespace NGenerics.DataStructures.Trees {
var comparisonValue = Comparer.Compare(childNode.Data, item);
if (comparisonValue == 0) {
if (comparisonValue == 0)
{
foundNode = childNode;
}
direction = comparisonValue < 0;
if ((IsBlack(childNode)) && (IsBlack(childNode[direction]))) {
if (IsRed(childNode[!direction])) {
if ((IsBlack(childNode)) && (IsBlack(childNode[direction])))
{
if (IsRed(childNode[!direction]))
{
parent = parent[lastDirection] = SingleRotation(childNode, direction);
} else if (IsBlack(childNode[direction])) {
}
else if (IsBlack(childNode[direction]))
{
var sibling = parent[!lastDirection];
if (sibling != null) {
if ((IsBlack(sibling.Left)) && (IsBlack(sibling.Right))) {
if (sibling != null)
{
if ((IsBlack(sibling.Left)) && (IsBlack(sibling.Right)))
{
parent.Color = NodeColor.Black;
sibling.Color = NodeColor.Red;
childNode.Color = NodeColor.Red;
} else {
}
else
{
var parentDirection = grandParent.Right == parent;
if (IsRed(sibling[lastDirection])) {
if (IsRed(sibling[lastDirection]))
{
grandParent[parentDirection] = DoubleRotation(parent, lastDirection);
} else if (IsRed(sibling[!lastDirection])) {
}
else if (IsRed(sibling[!lastDirection]))
{
grandParent[parentDirection] = SingleRotation(parent, lastDirection);
}
@ -134,18 +158,21 @@ namespace NGenerics.DataStructures.Trees {
}
}
if (foundNode != null) {
if (foundNode != null)
{
foundNode.Data = childNode.Data;
parent[parent.Right == childNode] = childNode[childNode.Left == null];
}
Tree = startNode.Right;
if (Tree != null) {
if (Tree != null)
{
((RedBlackTreeNode<T>)Tree).Color = NodeColor.Black;
}
if (foundNode != null) {
if (foundNode != null)
{
return true;
}
}
@ -164,7 +191,8 @@ namespace NGenerics.DataStructures.Trees {
/// <returns>
/// <c>true</c> if the specified node is red; otherwise, <c>false</c>.
/// </returns>
private static bool IsRed(RedBlackTreeNode<T> node) {
private static bool IsRed(RedBlackTreeNode<T> node)
{
return (node != null) && (node.Color == NodeColor.Red);
}
@ -175,7 +203,8 @@ namespace NGenerics.DataStructures.Trees {
/// <returns>
/// <c>true</c> if the specified node is black; otherwise, <c>false</c>.
/// </returns>
private static bool IsBlack(RedBlackTreeNode<T> node) {
private static bool IsBlack(RedBlackTreeNode<T> node)
{
return (node == null) || (node.Color == NodeColor.Black);
}
@ -185,28 +214,41 @@ namespace NGenerics.DataStructures.Trees {
/// <param name="node">The start node.</param>
/// <param name="item">The item.</param>
/// <returns>The node created in the insertion.</returns>
private RedBlackTreeNode<T> InsertNode(RedBlackTreeNode<T> node, T item) {
if (node == null) {
private RedBlackTreeNode<T> InsertNode(RedBlackTreeNode<T> node, T item)
{
if (node == null)
{
node = new RedBlackTreeNode<T>(item);
} else if (Comparer.Compare(item, node.Data) != 0) {
}
else if (Comparer.Compare(item, node.Data) != 0)
{
var direction = Comparer.Compare(node.Data, item) < 0;
node[direction] = InsertNode(node[direction], item);
if (IsRed(node[direction])) {
if (IsRed(node[!direction])) {
if (IsRed(node[direction]))
{
if (IsRed(node[!direction]))
{
node.Color = NodeColor.Red;
node.Left.Color = NodeColor.Black;
node.Right.Color = NodeColor.Black;
} else {
if (IsRed(node[direction][direction])) {
}
else
{
if (IsRed(node[direction][direction]))
{
node = SingleRotation(node, !direction);
} else if (IsRed(node[direction][!direction])) {
}
else if (IsRed(node[direction][!direction]))
{
node = DoubleRotation(node, !direction);
}
}
}
} else {
}
else
{
throw new ArgumentException(alreadyContainedInTheTree);
}
@ -219,7 +261,8 @@ namespace NGenerics.DataStructures.Trees {
/// <param name="node">The node on which to focus the rotation.</param>
/// <param name="direction">The direction of the rotation. If direction is equal to true, a right rotation is performed. Other wise, a left rotation.</param>
/// <returns>The new root of the cluster.</returns>
private static RedBlackTreeNode<T> SingleRotation(RedBlackTreeNode<T> node, bool direction) {
private static RedBlackTreeNode<T> SingleRotation(RedBlackTreeNode<T> node, bool direction)
{
var childSibling = node[!direction];
node[!direction] = childSibling[direction];
@ -237,7 +280,8 @@ namespace NGenerics.DataStructures.Trees {
/// <param name="node">The node on which to focus the rotation.</param>
/// <param name="direction">The direction of the rotation. If direction is equal to true, a right rotation is performed. Other wise, a left rotation.</param>
/// <returns>The new root of the cluster.</returns>
private static RedBlackTreeNode<T> DoubleRotation(RedBlackTreeNode<T> node, bool direction) {
private static RedBlackTreeNode<T> DoubleRotation(RedBlackTreeNode<T> node, bool direction)
{
node[!direction] = SingleRotation(node[!direction], !direction);
return SingleRotation(node, direction);
}

436
src/NGenerics/DataStructures/Trees/RedBlackTreeDictionary.cs

@ -1,3 +1,6 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
@ -22,222 +25,227 @@ using NGenerics.Patterns.Visitor;
namespace NGenerics.DataStructures.Trees
{
/// <summary>
/// An implementation of a Red-Black tree.
/// </summary>
/// <typeparam name="TKey">The type of the keys in the <see cref="RedBlackTree{TKey,TValue}"/>.</typeparam>
/// <typeparam name="TValue">The type of the values in the <see cref="RedBlackTree{TKey,TValue}"/>.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
/// <summary>
/// An implementation of a Red-Black tree.
/// </summary>
/// <typeparam name="TKey">The type of the keys in the <see cref="RedBlackTree{TKey,TValue}"/>.</typeparam>
/// <typeparam name="TValue">The type of the values in the <see cref="RedBlackTree{TKey,TValue}"/>.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
#if (!SILVERLIGHT && !WINDOWSPHONE)
//[Serializable]
#endif
public class RedBlackTree<TKey, TValue> : RedBlackTree<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue> // BinarySearchTreeBase<TKey, TValue>
{
#region Construction
/// <inheritdoc />
public RedBlackTree() : base(new KeyValuePairComparer<TKey, TValue>())
{
// Do nothing - the default Comparer will be used by the base class.
}
/// <inheritdoc/>
public RedBlackTree(IComparer<TKey> comparer)
: base(new KeyValuePairComparer<TKey, TValue>(comparer))
{
// Do nothing else.
}
/// <inheritdoc/>
public RedBlackTree(Comparison<TKey> comparison)
: base(new KeyValuePairComparer<TKey, TValue>(comparison))
{
// Do nothing else.
}
#endregion
#region Private Members
private RedBlackTreeNode<KeyValuePair<TKey, TValue>> FindNode(TKey key)
{
return base.FindNode(new KeyValuePair<TKey, TValue>(key, default(TValue))) as RedBlackTreeNode<KeyValuePair<TKey, TValue>>;
}
private bool Contains(KeyValuePair<TKey, TValue> item, bool checkValue) {
var node = FindNode(item);
if ((node != null) && !checkValue) {
return true;
}
return node != null && Equals(item.Value, node.Data.Value);
}
#endregion
#region IDictionary<TKey,TValue> Members
/// <summary>
/// Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <param name="key">The key of the element to remove.</param>
/// <returns>
/// true if the element is successfully removed; otherwise, false. This method also returns false if <paramref name="key"/> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key"/> is null.
/// </exception>
/// <exception cref="T:System.NotSupportedException">
/// The <see cref="T:System.Collections.Generic.IDictionary`2"/> is read-only.
/// </exception>
public bool Remove(TKey key) {
return Remove(new KeyValuePair<TKey, TValue>(key, default(TValue)));
}
/// <summary>
/// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <param name="key">The object to use as the key of the element to add.</param>
/// <param name="value">The object to use as the value of the element to add.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key"/> is null.
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// An element with the same key already exists in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </exception>
/// <exception cref="T:System.NotSupportedException">
/// The <see cref="T:System.Collections.Generic.IDictionary`2"/> is read-only.
/// </exception>
public void Add(TKey key, TValue value) {
if (Equals(key, null))
{
throw new ArgumentNullException("key");
}
Add(new KeyValuePair<TKey,TValue>(key, value));
}
/// <summary>
/// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key.
/// </summary>
/// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.</param>
/// <returns>
/// true if the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the key; otherwise, false.
/// </returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key"/> is null.
/// </exception>
public bool ContainsKey(TKey key) {
return Contains(new KeyValuePair<TKey, TValue>(key, default(TValue)), false);
}
/// <summary>
/// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the keys of the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <value></value>
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="Keys" lang="cs" title="The following example shows how to use the Keys property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="Keys" lang="vbnet" title="The following example shows how to use the Keys property."/>
/// </example>
public ICollection<TKey> Keys
{
get
{
// Get the keys in sorted order
var visitor = new KeyTrackingVisitor<TKey, TValue>();
var inOrderVisitor = new InOrderVisitor<KeyValuePair<TKey, TValue>>(visitor);
DepthFirstTraversal(inOrderVisitor);
return new ReadOnlyCollection<TKey>(visitor.TrackingList);
}
}
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="TryGetValue" lang="cs" title="The following example shows how to use the TryGetValue method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="TryGetValue" lang="vbnet" title="The following example shows how to use the TryGetValue method."/>
/// </example>
public bool TryGetValue(TKey key, out TValue value)
{
var node = FindNode(new KeyValuePair<TKey, TValue>(key, default(TValue)));
if (node == null)
{
value = default(TValue);
return false;
}
value = node.Data.Value;
return true;
}
/// <summary>
/// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the values in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <value></value>
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="Values" lang="cs" title="The following example shows how to use the Values property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="Values" lang="vbnet" title="The following example shows how to use the Values property."/>
/// </example>
public ICollection<TValue> Values
{
get
{
var visitor = new ValueTrackingVisitor<TKey, TValue>();
var inOrderVisitor = new InOrderVisitor<KeyValuePair<TKey, TValue>>(visitor);
DepthFirstTraversal(inOrderVisitor);
return new ReadOnlyCollection<TValue>(visitor.TrackingList);
}
}
/// <summary>
/// Gets or sets the value with the specified key.
/// </summary>
/// <value>The key of the item to set or get.</value>
public TValue this[TKey key]
{
get
{
var node = FindNode(key);
if (node == null)
{
throw new KeyNotFoundException("key");
}
return node.Data.Value;
}
set
{
var node = FindNode(key);
if (node == null)
{
throw new KeyNotFoundException("key");
}
node.Data = new KeyValuePair<TKey,TValue>(key, value);
}
}
#endregion
#region ICollection<KeyValuePair<TKey,TValue>> Members
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="Contains" lang="cs" title="The following example shows how to use the Contains method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="Contains" lang="vbnet" title="The following example shows how to use the Contains method."/>
/// </example>
public override bool Contains(KeyValuePair<TKey, TValue> item) {
return Contains(item, true);
}
#endregion
}
{
#region Construction
/// <inheritdoc />
public RedBlackTree() : base(new KeyValuePairComparer<TKey, TValue>())
{
// Do nothing - the default Comparer will be used by the base class.
}
/// <inheritdoc/>
public RedBlackTree(IComparer<TKey> comparer)
: base(new KeyValuePairComparer<TKey, TValue>(comparer))
{
// Do nothing else.
}
/// <inheritdoc/>
public RedBlackTree(Comparison<TKey> comparison)
: base(new KeyValuePairComparer<TKey, TValue>(comparison))
{
// Do nothing else.
}
#endregion
#region Private Members
private RedBlackTreeNode<KeyValuePair<TKey, TValue>> FindNode(TKey key)
{
return base.FindNode(new KeyValuePair<TKey, TValue>(key, default(TValue))) as RedBlackTreeNode<KeyValuePair<TKey, TValue>>;
}
private bool Contains(KeyValuePair<TKey, TValue> item, bool checkValue)
{
var node = FindNode(item);
if ((node != null) && !checkValue)
{
return true;
}
return node != null && Equals(item.Value, node.Data.Value);
}
#endregion
#region IDictionary<TKey,TValue> Members
/// <summary>
/// Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <param name="key">The key of the element to remove.</param>
/// <returns>
/// true if the element is successfully removed; otherwise, false. This method also returns false if <paramref name="key"/> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key"/> is null.
/// </exception>
/// <exception cref="T:System.NotSupportedException">
/// The <see cref="T:System.Collections.Generic.IDictionary`2"/> is read-only.
/// </exception>
public bool Remove(TKey key)
{
return Remove(new KeyValuePair<TKey, TValue>(key, default(TValue)));
}
/// <summary>
/// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <param name="key">The object to use as the key of the element to add.</param>
/// <param name="value">The object to use as the value of the element to add.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key"/> is null.
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// An element with the same key already exists in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </exception>
/// <exception cref="T:System.NotSupportedException">
/// The <see cref="T:System.Collections.Generic.IDictionary`2"/> is read-only.
/// </exception>
public void Add(TKey key, TValue value)
{
if (Equals(key, null))
{
throw new ArgumentNullException("key");
}
Add(new KeyValuePair<TKey, TValue>(key, value));
}
/// <summary>
/// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key.
/// </summary>
/// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.</param>
/// <returns>
/// true if the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the key; otherwise, false.
/// </returns>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key"/> is null.
/// </exception>
public bool ContainsKey(TKey key)
{
return Contains(new KeyValuePair<TKey, TValue>(key, default(TValue)), false);
}
/// <summary>
/// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the keys of the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <value></value>
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="Keys" lang="cs" title="The following example shows how to use the Keys property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="Keys" lang="vbnet" title="The following example shows how to use the Keys property."/>
/// </example>
public ICollection<TKey> Keys
{
get
{
// Get the keys in sorted order
var visitor = new KeyTrackingVisitor<TKey, TValue>();
var inOrderVisitor = new InOrderVisitor<KeyValuePair<TKey, TValue>>(visitor);
DepthFirstTraversal(inOrderVisitor);
return new ReadOnlyCollection<TKey>(visitor.TrackingList);
}
}
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="TryGetValue" lang="cs" title="The following example shows how to use the TryGetValue method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="TryGetValue" lang="vbnet" title="The following example shows how to use the TryGetValue method."/>
/// </example>
public bool TryGetValue(TKey key, out TValue value)
{
var node = FindNode(new KeyValuePair<TKey, TValue>(key, default(TValue)));
if (node == null)
{
value = default(TValue);
return false;
}
value = node.Data.Value;
return true;
}
/// <summary>
/// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the values in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
/// </summary>
/// <value></value>
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="Values" lang="cs" title="The following example shows how to use the Values property."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="Values" lang="vbnet" title="The following example shows how to use the Values property."/>
/// </example>
public ICollection<TValue> Values
{
get
{
var visitor = new ValueTrackingVisitor<TKey, TValue>();
var inOrderVisitor = new InOrderVisitor<KeyValuePair<TKey, TValue>>(visitor);
DepthFirstTraversal(inOrderVisitor);
return new ReadOnlyCollection<TValue>(visitor.TrackingList);
}
}
/// <summary>
/// Gets or sets the value with the specified key.
/// </summary>
/// <value>The key of the item to set or get.</value>
public TValue this[TKey key]
{
get
{
var node = FindNode(key);
if (node == null)
{
throw new KeyNotFoundException("key");
}
return node.Data.Value;
}
set
{
var node = FindNode(key);
if (node == null)
{
throw new KeyNotFoundException("key");
}
node.Data = new KeyValuePair<TKey, TValue>(key, value);
}
}
#endregion
#region ICollection<KeyValuePair<TKey,TValue>> Members
/// <inheritdoc />
/// <example>
/// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Trees\BinarySearchTreeBaseExamples.cs" region="Contains" lang="cs" title="The following example shows how to use the Contains method."/>
/// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Trees\BinarySearchTreeBaseExamples.vb" region="Contains" lang="vbnet" title="The following example shows how to use the Contains method."/>
/// </example>
public override bool Contains(KeyValuePair<TKey, TValue> item)
{
return Contains(item, true);
}
#endregion
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save