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/MockObjectEditor.cs')
-rw-r--r--Xamarin.PropertyEditing.Tests/MockObjectEditor.cs33
1 files changed, 27 insertions, 6 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs b/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs
index aa193df..8da782c 100644
--- a/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs
+++ b/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs
@@ -144,12 +144,14 @@ namespace Xamarin.PropertyEditing.Tests
public Task<AssignableTypesResult> GetAssignableTypesAsync (IPropertyInfo property, bool childTypes)
{
- if (this.assignableTypes == null) {
- return ReflectionObjectEditor.GetAssignableTypes (property, childTypes);
- } else if (!this.assignableTypes.TryGetValue (property, out IReadOnlyList<ITypeInfo> types))
- return Task.FromResult (new AssignableTypesResult (Enumerable.Empty<ITypeInfo> ().ToArray ()));
- else
- return Task.FromResult (new AssignableTypesResult (types));
+ if (this.assignableTypes != null) {
+ if (!this.assignableTypes.TryGetValue (property, out IReadOnlyList<ITypeInfo> types))
+ return Task.FromResult (new AssignableTypesResult (Enumerable.Empty<ITypeInfo> ().ToArray ()));
+ else
+ return Task.FromResult (new AssignableTypesResult (types));
+ }
+
+ return ReflectionObjectEditor.GetAssignableTypes (property.RealType, childTypes);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
@@ -310,6 +312,25 @@ namespace Xamarin.PropertyEditing.Tests
Value = default(T)
};
}
+
+ public Task<ITypeInfo> GetValueTypeAsync (IPropertyInfo property, PropertyVariation variation = null)
+ {
+ if (variation != null)
+ throw new NotImplementedException();
+
+ Type type = property.Type;
+ if (this.values.TryGetValue (property, out object value)) {
+ Type valueType = value.GetType ();
+ if (valueType.IsConstructedGenericType && valueType.GetGenericTypeDefinition () == typeof(ValueInfo<>)) {
+ value = valueType.GetProperty ("Value").GetValue (value);
+ type = value.GetType ();
+ } else
+ type = valueType;
+ }
+
+ var asm = new AssemblyInfo (type.Assembly.FullName, true);
+ return Task.FromResult<ITypeInfo> (new TypeInfo (asm, type.Namespace, type.Name));
+ }
#pragma warning restore CS1998
internal readonly IDictionary<IPropertyInfo, object> values = new Dictionary<IPropertyInfo, object> ();