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:
authorEric Maupin <ermaup@microsoft.com>2018-07-10 00:29:42 +0300
committerEric Maupin <ermaup@microsoft.com>2018-07-19 00:20:56 +0300
commitd549051f4f0808ed1642abd671df99c8a8a1ea77 (patch)
treee012eb2f81f8f1a5394fe55c720263d1d5cf81da /Xamarin.PropertyEditing.Tests/MockEditorProvider.cs
parenteb754860e632d96cb8ca6099e8d0c3d98f02c728 (diff)
[Core/Win] Bindings
Diffstat (limited to 'Xamarin.PropertyEditing.Tests/MockEditorProvider.cs')
-rw-r--r--Xamarin.PropertyEditing.Tests/MockEditorProvider.cs46
1 files changed, 43 insertions, 3 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockEditorProvider.cs b/Xamarin.PropertyEditing.Tests/MockEditorProvider.cs
index e2ca470..2225bca 100644
--- a/Xamarin.PropertyEditing.Tests/MockEditorProvider.cs
+++ b/Xamarin.PropertyEditing.Tests/MockEditorProvider.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Xamarin.PropertyEditing.Common;
+using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.Reflection;
using Xamarin.PropertyEditing.Tests.MockControls;
@@ -11,6 +13,26 @@ namespace Xamarin.PropertyEditing.Tests
{
public static readonly TargetPlatform MockPlatform = new TargetPlatform (new MockEditorProvider ());
+ public MockEditorProvider ()
+ {
+ }
+
+ public MockEditorProvider (IObjectEditor editor)
+ {
+ this.editorCache.Add (editor.Target, editor);
+ }
+
+ public IReadOnlyDictionary<Type, ITypeInfo> KnownTypes
+ {
+ get;
+ } = new Dictionary<Type, ITypeInfo> {
+ { typeof(PropertyBinding), typeof(MockBinding).ToTypeInfo() },
+ { typeof(CommonValueConverter), typeof(MockValueConverter).ToTypeInfo() },
+ { typeof(CommonBrush), typeof(CommonBrush).ToTypeInfo() },
+ { typeof(CommonSolidBrush), typeof(CommonSolidBrush).ToTypeInfo() },
+ { typeof(CommonColor), typeof(CommonColor).ToTypeInfo() }
+ };
+
public Task<IObjectEditor> GetObjectEditorAsync (object item)
{
if (this.editorCache.TryGetValue (item, out IObjectEditor cachedEditor)) {
@@ -23,9 +45,25 @@ namespace Xamarin.PropertyEditing.Tests
public async Task<IReadOnlyCollection<IPropertyInfo>> GetPropertiesForTypeAsync (ITypeInfo type)
{
- object obj = await CreateObjectAsync (type).ConfigureAwait (false);
- IObjectEditor editor = ChooseEditor (obj);
- return editor.Properties;
+ Type realType = ReflectionEditorProvider.GetRealType (type);
+ if (realType == null)
+ return Array.Empty<IPropertyInfo> ();
+
+ if (typeof(MockControl).IsAssignableFrom (realType)) {
+ object item = await CreateObjectAsync (type);
+ IObjectEditor editor = ChooseEditor (item);
+ return editor.Properties;
+ }
+
+ return ReflectionEditorProvider.GetPropertiesForType (realType);
+ }
+
+ public Task<AssignableTypesResult> GetAssignableTypesAsync (ITypeInfo type, bool childTypes)
+ {
+ if (type == KnownTypes[typeof(CommonValueConverter)])
+ return Task.FromResult (new AssignableTypesResult (new[] { type }));
+
+ return ReflectionObjectEditor.GetAssignableTypes (type, childTypes);
}
IObjectEditor ChooseEditor (object item)
@@ -35,6 +73,8 @@ namespace Xamarin.PropertyEditing.Tests
return new MockObjectEditor (msc);
case MockControl mc:
return new MockNameableEditor (mc);
+ case MockBinding mb:
+ return new MockBindingEditor (mb);
default:
return new ReflectionObjectEditor (item);
}