Last change
on this file since 17712 was
17473,
checked in by dpiringe, 5 years ago
|
#3026:
- refactored inheritance structure of json items, now the default JsonItem is an abstract class without properties Value and Range -> splitted up into new interfaces
- updated view models for new json item structure
- updated SingleLineArrayJsonWriter
|
File size:
1.3 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Threading.Tasks;
|
---|
9 | using System.Windows.Forms;
|
---|
10 | using HeuristicLab.PluginInfrastructure;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.JsonInterface.OptimizerIntegration {
|
---|
13 | public partial class ValueLookupJsonItemControl : LookupJsonItemControl {
|
---|
14 | private static IDictionary<Type, Type> JI2VM { get; set; }
|
---|
15 |
|
---|
16 | public ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) : base(vm) {
|
---|
17 | InitializeComponent();
|
---|
18 | InitCache();
|
---|
19 | if (vm.JsonItemReference != null && JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) {
|
---|
20 | IJsonItemVM tmp = (IJsonItemVM)Activator.CreateInstance(vmType);
|
---|
21 | tmp.Item = vm.JsonItemReference;
|
---|
22 | content.Controls.Clear();
|
---|
23 | UserControl control = tmp.Control;
|
---|
24 | content.Controls.Add(control);
|
---|
25 | control.Dock = DockStyle.Fill;
|
---|
26 |
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | private void InitCache() {
|
---|
31 | if(JI2VM == null) {
|
---|
32 | JI2VM = new Dictionary<Type, Type>();
|
---|
33 | foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) {
|
---|
34 | IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType);
|
---|
35 | JI2VM.Add(vm.TargetedJsonItemType, vmType);
|
---|
36 | }
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.