Changeset 17843 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ValueLookupJsonItemControl.cs
- Timestamp:
- 02/23/21 16:36:44 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ValueLookupJsonItemControl.cs
r17828 r17843 12 12 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 13 13 public partial class ValueLookupJsonItemControl : UserControl { 14 private static IDictionary<Type, Type> JI2VM { get; set; }15 14 16 public ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) { 15 private static IDictionary<Type, Type> ji2vm = null; 16 private static IDictionary<Type, Type> JI2VM { 17 get { 18 if (ji2vm == null) { 19 ji2vm = new Dictionary<Type, Type>(); 20 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 21 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 22 ji2vm.Add(vm.TargetedJsonItemType, vmType); 23 } 24 } 25 return ji2vm; 26 } 27 } 28 29 private ValueLookupJsonItemControl() { 17 30 InitializeComponent(); 18 InitCache(); 31 } 32 33 protected ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) { 34 InitializeComponent(); 19 35 if (vm.JsonItemReference != null && JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) { 20 36 IJsonItemVM tmp = (IJsonItemVM)Activator.CreateInstance(vmType); … … 29 45 } 30 46 31 private void InitCache() { 32 if(JI2VM == null) { 33 JI2VM = new Dictionary<Type, Type>(); 34 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 35 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 36 JI2VM.Add(vm.TargetedJsonItemType, vmType); 37 } 38 } 39 } 47 public static ValueLookupJsonItemControl Create(IValueLookupJsonItemVM vm) => new ValueLookupJsonItemControl(vm); 40 48 } 41 49 }
Note: See TracChangeset
for help on using the changeset viewer.