/// <summary> /// Recursive find by name starting by a reference /// </summary> /// <param name="vars">all variables</param> /// <param name="types">all types</param> /// <param name="name">name to find</param> /// <returns>an accu child</returns> public static Accumulate.AccuChild RecursiveFindByName(Dictionary <string, LuigiVariable> vars, Dictionary <string, Accumulate.Accu> types, string name) { string[] seq = name.Split('.'); if (seq.Length > 1) { if (vars.ContainsKey(seq[0].Substring(1))) { LuigiVariable v = vars[seq[0].Substring(1)]; if (v.LeftValueType == LuigiVariableType.VAR && v.RightValueType == LuigiVariableType.NEW) { // value est une reference sur un accu Accumulate.Accu a = Accumulate.Accu.FindByName(types, v.Value); Accumulate.AccuChild c = Accumulate.AccuChild.RecursiveFindByName(a, 1, seq); } else { throw new FormatException(String.Format("{0} is not a reference accu", seq[0])); } } else { throw new KeyNotFoundException(String.Format("Variable name {0} not found", seq[0])); } } else { throw new ArgumentException("bad name", "name"); } }
/// <summary> /// Clone this object /// </summary> /// <returns>new object</returns> public object Clone() { LuigiVariable pv = new LuigiVariable(); pv.Name = this.Name.Clone() as string; if (!String.IsNullOrEmpty(this.Value)) { pv.Value = this.Value.Clone() as string; } pv.leftValueType = this.leftValueType; pv.rightValueType = this.rightValueType; return(pv); }