- Timestamp:
- 11/26/19 13:27:23 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 11 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs
r17353 r17371 86 86 87 87 protected object GetDefaultValue(Type t) => t.IsValueType ? Activator.CreateInstance(t) : null; 88 89 90 88 91 #endregion 89 92 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r17353 r17371 63 63 <Compile Include="Attributes\ConvertableAttribute.cs" /> 64 64 <Compile Include="Constants.cs" /> 65 <Compile Include="Converters\CheckedItemListConverter.cs" /> 66 <Compile Include="Converters\ConfigurableConverter.cs" /> 67 <Compile Include="Converters\ItemCollectionConverter.cs" /> 65 68 <Compile Include="Converters\ParameterConverter.cs" /> 69 <Compile Include="Converters\PrimitiveConverter.cs" /> 66 70 <Compile Include="Converters\StorableConverter.cs" /> 67 71 <Compile Include="Converters\ValueLookupParameterConverter.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItem.cs
r17354 r17371 133 133 public static JsonItem BuildJsonItem(JObject obj, IDictionary<string, string> typeList) { 134 134 object val = obj[nameof(Value)]?.ToObject<object>(); 135 if (val is JContainer) 136 val = ((JContainer)val).ToObject<object[]>(); 135 if (val is JContainer) { 136 //try { 137 val = ((JContainer)val).ToObject<object[]>(); 138 /*} catch (Exception) { } 139 try { 140 val = ((JContainer)val).ToObject<object[,]>(); 141 } catch (Exception) { }*/ 142 } 143 137 144 138 145 return new JsonItem() { -
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.