/// <summary> /// Add a new variable in this scope /// </summary> /// <param name="prefix">prefix name</param> /// <param name="name">variable name</param> /// <param name="value">string value representation</param> /// <param name="belongsTo">current process name</param> /// <param name="isComputable">true if computable</param> /// <param name="dataType">desired data type</param> /// <returns>a reference to the newly created variable</returns> public IData Add(string prefix, string name, string value, string belongsTo, bool isComputable, EnumDataType dataType) { ScopeVariable var = new ScopeVariable(this, prefix, belongsTo, isComputable, dataType); var.Name = name; var.Value = value; this.scope.Add(var); return(var); }
/// <summary> /// Update variable infos /// </summary> /// <param name="prefix">prefix name</param> /// <param name="name">current name of the variable</param> /// <param name="value">string value representation</param> /// <param name="belongsTo">current process name</param> /// <param name="isComputable">true if computable</param> /// <param name="dataType">desired data type</param> /// <returns>a reference to the updated variable</returns> public IData Update(string prefix, string name, string value, string belongsTo, bool isComputable, EnumDataType dataType) { List <IData> list = this.IndexOf(name); int index = list.FindIndex(new Predicate <IData>(delegate(IData d) { return(d.Name == name); })); if (index != -1) { ScopeVariable v = new ScopeVariable(this, prefix, belongsTo, isComputable, dataType); v.Name = name; v.Value = value; list[index].CopyFrom(v, true); return(list[index]); } else { throw new ArgumentException("La variable '" + name + "' n'existe pas"); } }
public IData CopyFrom(IData from, bool changeScope) { if (from is ScopeVariable) { ScopeVariable x = from as ScopeVariable; if (!String.IsNullOrEmpty(x.realName)) { this.realName = x.realName; } else { this.realName = null; } if (changeScope) { this.scopeRef = x.scopeRef; } this.name = x.Name; this.type = x.DataType; foreach (KeyValuePair <EnumDataType, PrefixInfo> kv in x.prefixes) { if (this.prefixes.ContainsKey(kv.Key)) { this.prefixes[kv.Key] = new PrefixInfo(kv.Value.Prefix, kv.Value.BelongsTo, kv.Value.Value, kv.Value.IsComputable); } else { this.prefixes.Add(kv.Key, new PrefixInfo(kv.Value.Prefix, kv.Value.BelongsTo, kv.Value.Value, kv.Value.IsComputable)); } } this.UseThis(this.type); return(this); } else { throw new InvalidCastException(); } }