Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.PropertyEditing.Tests/MockBindingEditor.cs')
-rw-r--r--Xamarin.PropertyEditing.Tests/MockBindingEditor.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockBindingEditor.cs b/Xamarin.PropertyEditing.Tests/MockBindingEditor.cs
new file mode 100644
index 0000000..45ab099
--- /dev/null
+++ b/Xamarin.PropertyEditing.Tests/MockBindingEditor.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Xamarin.PropertyEditing.Reflection;
+
+namespace Xamarin.PropertyEditing.Tests
+{
+ internal class MockBindingEditor
+ : IObjectEditor
+ {
+ public MockBindingEditor (MockBinding binding)
+ {
+ Target = binding;
+ this.editor = new ReflectionObjectEditor (binding);
+ this.editor.PropertyChanged += (sender, args) => {
+ PropertyChanged?.Invoke (this, args);
+ };
+
+ KnownProperties = new Dictionary<IPropertyInfo, KnownProperty> {
+ { this.editor.Properties.Single (pi => pi.Name == nameof(MockBinding.Source)), PropertyBinding.SourceProperty },
+ { this.editor.Properties.Single (pi => pi.Name == nameof(MockBinding.SourceParameter)), PropertyBinding.SourceParameterProperty },
+ { this.editor.Properties.Single (pi => pi.Name == nameof(MockBinding.Path)), PropertyBinding.PathProperty },
+ { this.editor.Properties.Single (pi => pi.Name == nameof(MockBinding.Converter)), PropertyBinding.ConverterProperty },
+ { this.editor.Properties.Single (pi => pi.Name == nameof(MockBinding.TypeLevel)), PropertyBinding.TypeLevelProperty }
+ };
+ }
+
+ public event EventHandler<EditorPropertyChangedEventArgs> PropertyChanged;
+
+ public object Target
+ {
+ get;
+ }
+
+ public ITypeInfo TargetType => this.editor.TargetType;
+
+ public IReadOnlyCollection<IPropertyInfo> Properties => this.editor.Properties;
+
+ public IReadOnlyDictionary<IPropertyInfo, KnownProperty> KnownProperties
+ {
+ get;
+ }
+
+ public IObjectEditor Parent => null;
+
+ public IReadOnlyList<IObjectEditor> DirectChildren => null;
+
+ public Task<AssignableTypesResult> GetAssignableTypesAsync (IPropertyInfo property, bool childTypes)
+ {
+ return this.editor.GetAssignableTypesAsync (property, childTypes);
+ }
+
+ public Task SetValueAsync<T> (IPropertyInfo property, ValueInfo<T> value, PropertyVariation variation = null)
+ {
+ return this.editor.SetValueAsync (property, value, variation);
+ }
+
+ public Task<ValueInfo<T>> GetValueAsync<T> (IPropertyInfo property, PropertyVariation variation = null)
+ {
+ return this.editor.GetValueAsync<T> (property, variation);
+ }
+
+ private readonly ReflectionObjectEditor editor;
+ }
+} \ No newline at end of file