private static void Aibel() { Type type = GetUserType("Section"); var section = Create(type, GetArgs(type)); repository.Add(section); type = GetUserType("SDI"); var arg = GetArgs(type); var sdi = Create(type, arg); //arg.AssignArgumentValues(section, new DateTimePropertyNode(DateTime.Now)); //var sdi = Create(type, arg); repository.Add(sdi); type = GetUserType("CO"); arg = GetArgs(type); var res = new List <INode>(); for (int i = 0; i < arg.Arguments.Length; i++) { Console.Write(arg.Arguments[i].Name + ": "); var s = Console.ReadLine(); if (arg.Arguments[i].PropertyType == typeof(Relation)) { res.Add(section); } else { //res.Add(new StringPropertyNode(s)); } } arg.AssignArgumentValues(res.ToArray()); var co = Create(type, arg); repository.Add(co); type = GetUserType("HasCO"); var rel = sdi.RelateTo(type, co, true); repository.Add(rel); var x = sdi.Relations(repository); var y = co.Relations(repository); }
public void Execute() { if (!CanExecute()) { throw new OperationCanceledException($"{typeof(NewDynamicRelationCommand).Name} cannot be excuted"); } Result = new DynamicRelation(nameSpace, name, originTypes, targetTypes); repository.Add(Result as ISimObject); }
public void Execute() { if (!CanExecute()) { throw new OperationCanceledException(); } Result = new DynamicNode(nameSpace, name, isVisible); repository.Add(Result as ISimObject); }
public void Execute() { if (!CanExecute()) { throw new OperationCanceledException($"Cannot create new instance of{typeof(T)}", new CancellationToken(true)); } var newNode = new T(); repository.Add(newNode); Result = newNode; }
public void Execute() { if (!CanExecute()) { throw new OperationCanceledException($"{GetType().Name} cannot be excuted"); } var newRelation = new T() { Origin = origin, Target = target }; repository.Add(newRelation); Result = newRelation; }
public void Execute() { if (!CanExecute()) { throw new OperationCanceledException($"{GetType().Name} cannot be excuted"); } JsonSerializer serializer = new JsonSerializer(); var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), $@"SIM\Json\{nameSpace}.json"); StreamReader reader = new StreamReader(path); JsonSerializerSettings settings = new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Objects }; Result = JsonConvert.DeserializeObject <IEnumerable <DynamicObject> >(reader.ReadToEnd()); reader.Close(); foreach (var item in Result as IEnumerable <DynamicObject> ) { repository.Add(item); } }