private static List <ScriptVariable> removeParamRecursionAux(IList <ScriptVariable> args, Dictionary <ScriptVariable, ScriptVariable> cloneMap) { List <ScriptVariable> ret = new List <ScriptVariable>(); foreach (var arg in args) { ScriptVariable cloned; if (arg == null) { ret.Add(null); continue; } if (cloneMap.TryGetValue(arg, out cloned)) { ret.Add(cloned); continue; } ListVariable list = arg as ListVariable; if (list != null) { ListVariable tmp = new ListVariable(); cloneMap[list] = tmp; tmp.AddRange(removeParamRecursionAux(list.Value, cloneMap)); ret.Add(tmp); } else { cloned = arg.Clone(); cloneMap[arg] = cloned; ret.Add(cloned); } } return(ret); }
/// <summary> /// 変数の値の型に応じて名前付きスクリプト変数を作成します /// </summary> /// <param name="variable">変数の値</param> /// <param name="stringDelimiter">文字列を分割する区切り文字</param> /// <returns></returns> public static RefScriptVariable Create(ScriptVariable value, IEnumerable <char> stringDelimiter) { StringVariable str = value as StringVariable; if (str != null) { return(new RefConcatStringVariable(str, stringDelimiter)); } ListVariable list = value as ListVariable; if (list != null) { return(new RefListVariable(list, stringDelimiter)); } return(new RefScriptVariable(value)); }
public ScriptVariable this[string key] { get { foreach (ScriptVariable variable in _value) { ListVariable list = variable as ListVariable; if (list != null && list.Value.Count >= 2) { if (list.Value[0].IsNull()) { continue; } if (list.Value[0].ToString() == key) { return(list.Value[1]); } } } return(null); } set { foreach (ScriptVariable variable in _value) { ListVariable list = variable as ListVariable; if (list != null && list.Value.Count >= 2) { if (list.Value[0].IsNull()) { continue; } if (list.Value[0].ToString() == key) { list.SetIndexedValue(1, value); } } } _value.Add(new ListVariable(new StringVariable(key), value)); } }
public RefListVariable(ListVariable listVariable, IEnumerable <char> stringDelimiters) : base(listVariable) { _list = listVariable.Value.Select(v => RefScriptVariable.Create(v, stringDelimiters)).ToList(); }