public bool Set <T>(string variableKey, T value = default(T), bool skipIfExists = false) { string variable = ParameterDicUtils.GetVariable(variableKey); string[] variableSplit = variable.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (variableSplit.Length > 1) { //If have more than one hierarchy (e.g. {Code.Directory.Temp}) //Remove last node, and construct as variable key (e.g. {Code.Directory})) string parentKey = "{" + String.Join(".", variableSplit.Take(variableSplit.Length - 1)) + "}"; string childPath = variableSplit.Last(); string childKey = "{" + childPath + "}"; object parentObject = Get(parentKey); //If ParentObject not found, create as ParameterDic. if (parentObject == null) { parentObject = new ParameterDic(); Set <ParameterDic>(parentKey, (ParameterDic)parentObject, false); } if (parentObject is IParameterDic) { (parentObject as IParameterDic).Set <T>(childKey, value, skipIfExists); return(true); } else { TypeInfoUtils.SetProperty(parentObject, childPath, value); return(true); } } else if (_store.ContainsKey(variable)) { if (!skipIfExists) { if (!(_store[variable] is T) || !(_store[variable].Equals(value))) { _store[variable] = value; return(true); } else { return(false); } } else { return(false); } } else { _store.Add(variable, value); return(true); } }
public void Run(IScriptCommand cmd, ParameterDic initialParameters) { Run(new Queue <IScriptCommand>(new[] { cmd }), initialParameters); }
public override IScriptCommand Execute(IParameterDic pm) { Value = new ParameterDic(); return(base.Execute(pm)); }
public static void SetProgress(this ParameterDic pd, IProgress <TransferProgress> progress) { pd.Set("{Progress}", progress); }
public static IProgress <TransferProgress> GetProgress(this ParameterDic pd) { return(pd.Get <IProgress <TransferProgress> >("{Progress}", NullTransferProgress.Instance)); }