diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-04-18 22:23:14 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-05-01 00:53:55 +0300 |
commit | fa28e9cca17eb158ea9a59202f448b041c43a9f4 (patch) | |
tree | 21a1277a7fc23ed351c1b8a50120c6f54f0f2296 /Xamarin.PropertyEditing | |
parent | d6321d4d839b8515d76e8ea5b5e7a5e2a3c84557 (diff) |
[Core] Move IEditorProvider into TargetPlatform
Diffstat (limited to 'Xamarin.PropertyEditing')
5 files changed, 26 insertions, 26 deletions
diff --git a/Xamarin.PropertyEditing/TargetPlatform.cs b/Xamarin.PropertyEditing/TargetPlatform.cs index 2cc42fc..940307a 100644 --- a/Xamarin.PropertyEditing/TargetPlatform.cs +++ b/Xamarin.PropertyEditing/TargetPlatform.cs @@ -10,6 +10,22 @@ namespace Xamarin.PropertyEditing /// </summary> public sealed class TargetPlatform { + public TargetPlatform (IEditorProvider provider) + { + if (provider == null) + throw new ArgumentNullException (nameof(provider)); + + EditorProvider = provider; + } + + /// <summary> + /// Gets the <see cref="IEditorProvider"/> associated with this platform. + /// </summary> + public IEditorProvider EditorProvider + { + get; + } + /// <summary> /// Gets or sets whether the platform supports custom expressions (default false). /// </summary> @@ -43,10 +59,5 @@ namespace Xamarin.PropertyEditing set; } - public static readonly TargetPlatform Default = new TargetPlatform { - GroupedTypes = new Dictionary<Type, string> { - { typeof(CommonBrush), "Brush" } - } - }; } } diff --git a/Xamarin.PropertyEditing/ViewModels/ObjectPropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/ObjectPropertyViewModel.cs index 16f1b21..e491b23 100644 --- a/Xamarin.PropertyEditing/ViewModels/ObjectPropertyViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/ObjectPropertyViewModel.cs @@ -26,16 +26,13 @@ namespace Xamarin.PropertyEditing.ViewModels internal class ObjectPropertyViewModel : PropertyViewModel { - public ObjectPropertyViewModel (IEditorProvider provider, TargetPlatform targetPlatform, IPropertyInfo property, IEnumerable<IObjectEditor> editors) + public ObjectPropertyViewModel (TargetPlatform targetPlatform, IPropertyInfo property, IEnumerable<IObjectEditor> editors) : base (targetPlatform, property, editors) { - if (provider == null) - throw new ArgumentNullException (nameof(provider)); if (targetPlatform == null) throw new ArgumentNullException (nameof(targetPlatform)); - this.provider = provider; - ValueModel = new ObjectViewModel (provider, targetPlatform); + ValueModel = new ObjectViewModel (targetPlatform); RequestCurrentValueUpdate(); QueryTypes(); @@ -171,7 +168,6 @@ namespace Xamarin.PropertyEditing.ViewModels } } - private readonly IEditorProvider provider; private AsyncValue<IReadOnlyDictionary<IAssemblyInfo, ILookup<string, ITypeInfo>>> assignableTypes; private bool createInstancePending; private string customExpression; @@ -282,7 +278,7 @@ namespace Xamarin.PropertyEditing.ViewModels } await SetValueAsync (new ValueInfo<object> { - Value = await this.provider.CreateObjectAsync (selectedType), + Value = await TargetPlatform.EditorProvider.CreateObjectAsync (selectedType), ValueDescriptor = selectedType, Source = ValueSource.Local }); diff --git a/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs b/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs index 63f52c0..1d560e8 100644 --- a/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/ObjectViewModel.cs @@ -3,8 +3,8 @@ namespace Xamarin.PropertyEditing.ViewModels internal class ObjectViewModel : PropertiesViewModel { - public ObjectViewModel (IEditorProvider provider, TargetPlatform targetPlatform) - : base (provider, targetPlatform) + public ObjectViewModel (TargetPlatform targetPlatform) + : base (targetPlatform) { } } diff --git a/Xamarin.PropertyEditing/ViewModels/PanelViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PanelViewModel.cs index b75167c..ec09f31 100644 --- a/Xamarin.PropertyEditing/ViewModels/PanelViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/PanelViewModel.cs @@ -7,8 +7,8 @@ namespace Xamarin.PropertyEditing.ViewModels internal class PanelViewModel : PropertiesViewModel, IFilterable { - public PanelViewModel (IEditorProvider provider, TargetPlatform targetPlatform) - : base (provider, targetPlatform) + public PanelViewModel (TargetPlatform targetPlatform) + : base (targetPlatform) { ArrangeModes = new List<ArrangeModeViewModel> { new ArrangeModeViewModel (PropertyArrangeMode.Name, this), diff --git a/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs index d4ef9cb..51e0d27 100644 --- a/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/PropertiesViewModel.cs @@ -13,14 +13,11 @@ namespace Xamarin.PropertyEditing.ViewModels internal abstract class PropertiesViewModel : NotifyingObject, INotifyDataErrorInfo { - public PropertiesViewModel (IEditorProvider provider, TargetPlatform targetPlatform) + public PropertiesViewModel (TargetPlatform targetPlatform) { - if (provider == null) - throw new ArgumentNullException (nameof (provider)); if (targetPlatform == null) throw new ArgumentNullException (nameof(targetPlatform)); - EditorProvider = provider; TargetPlatform = targetPlatform; this.selectedObjects.CollectionChanged += OnSelectedObjectsChanged; @@ -109,10 +106,7 @@ namespace Xamarin.PropertyEditing.ViewModels public bool HasErrors => this.errors.IsValueCreated && this.errors.Value.Count > 0; - protected IEditorProvider EditorProvider - { - get; - } + protected IEditorProvider EditorProvider => TargetPlatform.EditorProvider; protected IReadOnlyList<IObjectEditor> ObjectEditors => this.objEditors; @@ -450,8 +444,6 @@ namespace Xamarin.PropertyEditing.ViewModels : typeof(PredefinedValuesViewModel<>).MakeGenericType (hasPredefinedValues.GenericTypeArguments[0]); return (PropertyViewModel) Activator.CreateInstance (type, TargetPlatform, property, this.objEditors); - } else if (property.Type == typeof(object)) { - return new ObjectPropertyViewModel (EditorProvider, TargetPlatform, property, this.objEditors); } if (ViewModelMap.TryGetValue (property.Type, out var vmFactory)) @@ -475,6 +467,7 @@ namespace Xamarin.PropertyEditing.ViewModels { typeof(CommonSize), (tp,p,e) => new SizePropertyViewModel (tp, p, e) }, { typeof(CommonRectangle), (tp,p,e) => new RectanglePropertyViewModel (tp, p, e) }, { typeof(CommonThickness), (tp,p, e) => new ThicknessPropertyViewModel (tp, p, e) }, + { typeof(object), (tp,p,e) => new ObjectPropertyViewModel (tp,p,e) }, }; } } |