/**
         * 将Dto传进来,对象属性都转成字典输出
         */
        public static ParametersContainer ToParametersContainer(Object obj)
        {
            ParametersContainer parametersContainer = new ParametersContainer();
            Type t = obj.GetType();

            PropertyInfo[] propertyArray = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (PropertyInfo p in propertyArray)
            {
                //MethodInfo method = p.GetGetMethod();

                //if (method != null && method.IsPublic)
                //{
                //    parametersContainer.Add(p.Name, method.Invoke(obj, new Object[] {}));
                //}

                if (p.CanRead)
                {
                    TransferToDictionaryKeyAttribute attribute =
                        p.GetCustomAttribute(typeof(TransferToDictionaryKeyAttribute)) as TransferToDictionaryKeyAttribute;

                    if (attribute == null)
                    {
                        parametersContainer.Add(p.Name, p.GetValue(obj));
                    }
                    else
                    {
                        parametersContainer.Add(attribute.Key, p.GetValue(obj));
                    }
                }
            }
            return(parametersContainer);
        }
示例#2
0
 public GetListDataArgs()
 {
     PagingInfo = new PagingInfo();
     Parameters = new ParametersContainer();
 }