Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PropertyGroupedEditorSelector.cs « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c3514c6283cd58e82fd3e31480cf884ae55f3896 (plain)
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
using System;
using System.Collections.Generic;

using Xamarin.PropertyEditing.ViewModels;

namespace Xamarin.PropertyEditing.Mac
{
	internal class PropertyGroupedEditorSelector
		: PropertyEditorSelector
	{
		public override IEditorView GetEditor (IHostResourceProvider hostResources, EditorViewModel vm)
		{
			if (hostResources == null)
				throw new ArgumentNullException (nameof (hostResources));

			Type propertyType = vm.GetType ();
			if (GroupedViewModelTypes.TryGetValue (propertyType, out Type nativeEditorType)) {
				return (IEditorView)Activator.CreateInstance (nativeEditorType, hostResources);
			}

			return base.GetEditor (hostResources, vm);
		}

		private static readonly Dictionary<Type, Type> GroupedViewModelTypes = new Dictionary<Type, Type> {
			{typeof(BrushPropertyViewModel), typeof(BrushTabViewController)}
		};
	}
}