Example #1
0
        private StateVariable CreateAndAdd <T>(StateVariableKey <T> key)
        {
            var v = new StateVariable(key.Key, key.DefaultValue);

            stateVariables.Add(v);
            return(v);
        }
Example #2
0
        private StateVariable FindVariable <T>(StateVariableKey <T> key)
        {
            StateVariable variable       = null;
            var           expectedString = key.Key;

            //Search for an already existing variable
            foreach (var stateVariable in stateVariables)
            {
                if (stateVariable.Key.Equals(expectedString, StringComparison.InvariantCulture))
                {
                    variable = stateVariable;
                }
            }
            //Check if found a coresponding variable, or create a new one with the default value
            return(variable ?? (variable = CreateAndAdd(key)));
        }