Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 public void Run(IScriptCommand cmd, ParameterDic initialParameters)
 {
     Run(new Queue <IScriptCommand>(new[] { cmd }), initialParameters);
 }
Ejemplo n.º 3
0
 public override IScriptCommand Execute(IParameterDic pm)
 {
     Value = new ParameterDic();
     return(base.Execute(pm));
 }
Ejemplo n.º 4
0
 public static void SetProgress(this ParameterDic pd, IProgress <TransferProgress> progress)
 {
     pd.Set("{Progress}", progress);
 }
Ejemplo n.º 5
0
 public static IProgress <TransferProgress> GetProgress(this ParameterDic pd)
 {
     return(pd.Get <IProgress <TransferProgress> >("{Progress}", NullTransferProgress.Instance));
 }