Esempio n. 1
0
        public void Add(string name, CustomValue value)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Имя параметра не может быть пусто");
            }

            this.Add(new ParamValue((this.Prefix + "." + name).Trim('.'), value));
        }
Esempio n. 2
0
        public void Set(string name, CustomValue value)
        {
            if (value == null)
            {
                return;
            }

            var current = this.Get(name);

            if (current != null)
            {
                this.Remove(current);
            }

            this.Add(new ParamValue(name, value));
        }
Esempio n. 3
0
        static public CustomValue Convert(CustomValue value, CustomValue.ValueType type)
        {
            if (value == null)
            {
                return(null);
            }

            if (value.Type == type)
            {
                return(value);
            }

            switch (type)
            {
            case ValueType.Number:
                return(Double.Parse(value.ToString()));

            case ValueType.Date:
                return(DateTime.ParseExact(value.ToString(), CustomValueDate.DEFAULT_FORMAT, null));

            case ValueType.Bool:
                string val = value.ToString().ToLower().Trim();
                if (val.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(CustomValueBool.True);
                }
                else if (val.Equals("false", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(CustomValueBool.False);
                }
                else if (val == "1")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                return(value.ToString());
            }
        }
Esempio n. 4
0
 public ParamValue(string name, CustomValue value)
 {
     Name  = name;
     Value = value;
 }
Esempio n. 5
0
 public void SetParam(string name, CustomValue value)
 {
     this.Params.Set(new ParamValue(name, value));
 }