1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
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<IReadOnlyCollection<PropertyVariation>> GetPropertyVariantsAsync (IPropertyInfo property)
{
throw new NotSupportedException();
}
public Task RemovePropertyVariantAsync (IPropertyInfo property, PropertyVariation variant)
{
throw new NotSupportedException();
}
public Task SetValueAsync<T> (IPropertyInfo property, ValueInfo<T> value, PropertyVariation variations = null)
{
return this.editor.SetValueAsync (property, value, variations);
}
public Task<ValueInfo<T>> GetValueAsync<T> (IPropertyInfo property, PropertyVariation variations = null)
{
return this.editor.GetValueAsync<T> (property, variations);
}
private readonly ReflectionObjectEditor editor;
}
}
|