Changeset 17371 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverter.cs
- Timestamp:
- 11/26/19 13:27:23 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItemConverter.cs
r17353 r17371 6 6 using HeuristicLab.Core; 7 7 using HeuristicLab.Data; 8 using HeuristicLab.PluginInfrastructure; 9 using HEAL.Attic; 10 using System.Collections; 8 11 9 12 namespace HeuristicLab.JsonInterface { … … 30 33 if (!Converters.ContainsKey(type)) 31 34 Converters.Add(type, new ConverterPriorityContainer() { Converter = converter, Priority = priority }); 35 } 36 37 38 public static void Register(string atticGuid, IJsonItemConverter converter, int priority) => 39 Register(new Guid(atticGuid), converter, priority); 40 41 public static void Register(Guid atticGuid, IJsonItemConverter converter, int priority) { 42 if (Mapper.StaticCache.TryGetType(atticGuid, out Type type)) { 43 Register(type, converter, priority); 44 } 32 45 } 33 46 … … 68 81 return best.Converter; 69 82 } 83 84 Type t = Mapper.StaticCache.GetType(new Guid("25137f88-66b9-48d7-a2bd-60190082e044")); 85 86 87 70 88 return new DummyConverter(); 71 89 } … … 113 131 Register(typeof(IConstrainedValueParameter<>), new ConstrainedValueParameterConverter(), 3); 114 132 Register(typeof(ICheckedMultiOperator<>), new MultiCheckedOperatorConverter(), 3); 133 134 //ApplicationManager.Manager 135 // "25137f88-66b9-48d7-a2bd-60190082e044" 136 //new Guid("25137f88-66b9-48d7-a2bd-60190082e044") 137 // ISymbol 138 139 Register("25137f88-66b9-48d7-a2bd-60190082e044", 140 new ConfigurableConverter() 141 .Primitive("InitialFrequency", ElementType.Property, new object[] { 0.0, 1.0 }) 142 .Primitive("Enabled", ElementType.Property, true) 143 .Primitive("MinimumArity", ElementType.Property, 0) 144 .Primitive("MaximumArity", ElementType.Property, 10), 145 5); 146 147 // Dataset 148 Register("49F4D145-50D7-4497-8D8A-D190CD556CC8", 149 new ConfigurableConverter() //TODO: set guid to enable inheritance? 150 /*.PrimitiveEnumerable("VariableNames", ElementType.Property) 151 .PrimitiveEnumerable("DoubleVariables", ElementType.Property) 152 .PrimitiveEnumerable("StringVariables", ElementType.Property) 153 .PrimitiveEnumerable("DateTimeVariables", ElementType.Property)*/ 154 .PrimitiveEnumerable("storableData", ElementType.Field, new double[,] { }), 155 5); 156 157 // ICheckedItemList<> 158 Register("ba4a82ca-92eb-47a1-95a7-f41f6ef470f4", 159 new ConfigurableConverter() 160 .This((o,t) => { 161 dynamic itemList = o as dynamic; 162 IList<JsonItem> jsonItems = new List<JsonItem>(); 163 int count = 0; 164 foreach(var obj in itemList) { 165 IItem item = obj as IItem; 166 JsonItem checkedStatus = new JsonItem() { 167 Name = "Checked", 168 Value = itemList.ItemChecked(obj), 169 Range = new object[] { false, true } 170 }; 171 JsonItem value = Extract(item); 172 173 jsonItems.Add(new JsonItem() { 174 Name = item.ItemName + count++, 175 Parameters = new JsonItem[] { 176 checkedStatus, value 177 }, 178 Type = item.GetType().AssemblyQualifiedName 179 }); 180 } 181 return jsonItems; 182 }), 183 5); 115 184 } 116 185 }
Note: See TracChangeset
for help on using the changeset viewer.