Ejemplo n.º 1
0
        internal static ParamsObject CreateFromStaticObject(object obj)
        {
            Type         t   = obj.GetType();
            ParamsObject ret = new ParamsObject();

            foreach (var p in t.GetProperties())
            {
                var r = Attribute.IsDefined(p, typeof(ParamAttribute));
                if (!r)
                {
                    continue;
                }

                object propValue = p.GetValue(obj);
                if (propValue != null)
                {
                    if (propValue.GetType() == typeof(List <string>))
                    {
                        string newValue = "";
                        foreach (object item in (IList)propValue)
                        {
                            if (newValue.Length > 0)
                            {
                                newValue += " \r\n";
                            }
                            newValue += item.ToString();
                        }
                        propValue = newValue;
                    }
                    ret.Add(p.Name, propValue);
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
 private void Expand(ParamsObject paramsObj)
 {
     foreach (KeyValuePair <string, object> param in paramsObj)
     {
         storage.Add(param.Key, param.Value);
     }
 }
Ejemplo n.º 3
0
        internal static ParamsObject CreateFromStaticObject(object obj)
        {
            Type t = obj.GetType();
            ParamsObject ret = new ParamsObject();
            foreach (var p in t.GetProperties())
            {
                var r = Attribute.IsDefined(p, typeof(ParamAttribute));
                if (!r)
                    continue;

                object propValue = p.GetValue(obj);
                if (propValue != null)
                {
                    if (propValue.GetType() == typeof(List<string>))
                    {
                        string newValue = "";
                        foreach (object item in (IList)propValue)
                        {
                            if (newValue.Length > 0)
                                newValue += " \r\n";
                            newValue += item.ToString();
                        }
                        propValue = newValue;
                    }
                    ret.Add(p.Name, propValue);
                }
            }
            return ret;

        }
Ejemplo n.º 4
0
 private void Expand(ParamsObject paramsObj)
 {
     foreach (KeyValuePair<string, object> param in paramsObj)
     {
         storage.Add(param.Key, param.Value);
     }
 }
Ejemplo n.º 5
0
        public static ParamsObject operator +(ParamsObject paramsObj1, ParamsObject paramsObj2)
        {
            var res = new ParamsObject();

            if (paramsObj1 != null)
            {
                res.Expand(paramsObj1);
            }

            if (paramsObj2 != null)
            {
                res.Expand(paramsObj2);
            }

            return(res);
        }
Ejemplo n.º 6
0
        public static ParamsObject operator +(ParamsObject paramsObj1, ParamsObject paramsObj2)
        {
            var res = new ParamsObject();

            if (paramsObj1 != null)
            {
                res.Expand(paramsObj1);
            }

            if (paramsObj2 != null)
            {
                res.Expand(paramsObj2);
            }

            return res;
        }