diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-06-07 21:48:47 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-06-12 19:59:22 +0300 |
commit | 3e1160f9979508063c4ba451173454152615c179 (patch) | |
tree | 50a4a92ae88a206afcff3488b7224ebd006c55f1 /Xamarin.PropertyEditing.Tests | |
parent | 02be1018f98ed644b7427d90395b7dc6b4bac0ee (diff) |
[Tests] Support resources in mock editor for brushes
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r-- | Xamarin.PropertyEditing.Tests/MockObjectEditor.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs b/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs index c9fbfbd..fdd59ae 100644 --- a/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs +++ b/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs @@ -247,11 +247,14 @@ namespace Xamarin.PropertyEditing.Tests Source = underlyingInfo?.Source ?? ValueSource.Local }, typeof(ValueInfo<T>)); } else { + object descriptor = null; ValueSource source = ValueSource.Local; Type valueType = value.GetType (); if (valueType.IsConstructedGenericType && valueType.GetGenericTypeDefinition () == typeof(ValueInfo<>)) { source = (ValueSource)valueType.GetProperty ("Source").GetValue (value); + descriptor = valueType.GetProperty (nameof (ValueInfo<T>.ValueDescriptor)).GetValue (value); value = valueType.GetProperty ("Value").GetValue (value); + valueType = valueType.GetGenericArguments ()[0]; } object newValue; @@ -259,7 +262,14 @@ namespace Xamarin.PropertyEditing.Tests if (converter != null && converter.TryConvert (value, typeof(T), out newValue)) { return new ValueInfo<T> { Source = source, - Value = (T)newValue + Value = (T)newValue, + ValueDescriptor = descriptor + }; + } else if (typeof(T).IsAssignableFrom (valueType)) { + return new ValueInfo<T> { + Source = source, + Value = (T)value, + ValueDescriptor = descriptor }; } } |