Exemplo n.º 1
0
        public void Combine(VariableRegistry otherRegistry, bool removeMissing = false)
        {
            //Below doesn't work for added variables
            Dictionary <string, VariableRegistryItem> vars = new Dictionary <string, VariableRegistryItem>();

            foreach (var variable in otherRegistry._variables)
            {
                if (removeMissing)
                {
                    VariableRegistryItem local = _variables.ContainsKey(variable.Key) ? _variables[variable.Key] : null;
                    if (local != null)
                    {
                        local.Merge(variable.Value);
                    }
                    else
                    {
                        local = variable.Value;
                    }

                    vars.Add(variable.Key, local);
                }
                else
                {
                    Register(variable.Key, variable.Value);
                }
            }

            if (removeMissing)
            {
                _variables = vars;
            }
        }
Exemplo n.º 2
0
 public void Register(string name, VariableRegistryItem varItem)
 {
     if (!_variables.ContainsKey(name))
     {
         _variables.Add(name, varItem);
     }
     else
     {
         _variables[name].Merge(varItem);
     }
 }
Exemplo n.º 3
0
        internal void Merge(VariableRegistryItem variableRegistryItem)
        {
            this.Default = variableRegistryItem.Default;
            this.Title   = variableRegistryItem.Title;
            this.Remark  = variableRegistryItem.Remark;
            this.Min     = variableRegistryItem.Min;
            this.Max     = variableRegistryItem.Max;

            if (this.Value == null || variableRegistryItem.Default.GetType() != this.Value.GetType())
            {
                this.Value = variableRegistryItem.Default;
            }
        }
Exemplo n.º 4
0
        internal void Merge(VariableRegistryItem variableRegistryItem)
        {
            this.Default = variableRegistryItem.Default;
            this.Title   = variableRegistryItem.Title;
            this.Remark  = variableRegistryItem.Remark;
            this.Min     = variableRegistryItem.Min;
            this.Max     = variableRegistryItem.Max;
            Type typ         = this.Value.GetType();
            Type defaultType = variableRegistryItem.Default.GetType();

            if (!defaultType.Equals(typ) && this.Value.GetType().Equals(typeof(long)) && TypeUtils.IsNumericType(defaultType))
            {
                this.Value = Convert.ChangeType(this.Value, defaultType);
            }
            else if (this.Value == null && !defaultType.Equals(typ))
            {
                this.Value = variableRegistryItem.Default;
            }
        }