Example #1
0
        private void PickUp(object o, string prefix, string label, DCInfo info)
        {
            DCPartInfo part = CreateDCPart(info, label);

            foreach (PropertyInfo prop in o.GetType().GetProperties())
            {
                if (Attribute.IsDefined(prop, typeof(IgnoreAttribute)))
                {
                    IgnoreAttribute attr = GetAttribute <IgnoreAttribute>(prop);

                    if (attr.Fields == null || attr.Fields.Length == 0)
                    {
                        continue;
                    }
                }

                string name = !String.IsNullOrEmpty(prefix) ? String.Format("{0}-{1}", prefix, prop.Name) : prop.Name;

                if (Attribute.IsDefined(prop, typeof(ChildrenAttribute)))
                {
                    DescAttribute desc = GetAttribute <DescAttribute>(prop);
                    PickUp(prop.GetValue(o, null), name,
                           desc != null ? desc.Title : String.Empty, info);
                }
                else if (Attribute.IsDefined(prop, typeof(OptionAttribute)))
                {
                    part.Params.Add(GetDCParam(prop, name));
                }
            }

            SortParam(part);
        }
Example #2
0
        /// <summary>
        /// 创建DcPart
        /// </summary>
        /// <param name="info"></param>
        /// <param name="label"></param>
        #region DCPartInfo CreateDCPart(DCInfo info, string label)
        private DCPartInfo CreateDCPart(DCInfo info, string label)
        {
            DCPartInfo part = new DCPartInfo();

            part.Name = label;
            info.Parts.Add(part);
            return(part);
        }
Example #3
0
        private void PickUp(object o, string prefix, string label, DCInfo info)
        {
            //反射元标记MetaData,筛选[属性名/ParameterAttribute]键值对
            Dictionary <string, ParameterAttribute> dictParams = BaseControlHelper.FilterParamAttrs(o, prefix);

            //获取DataControlParameters集合
            DCPartInfo part = CreateDCPart(info, label);

            part.Params = GetDataControlParameters(dictParams);

            //排序
            SortParam(part);
        }
Example #4
0
 /// <summary>
 /// 按Weight排序
 /// </summary>
 /// <param name="part"></param>
 #region void SortParam(DCPartInfo part)
 private void SortParam(DCPartInfo part)
 {
     part.Params.Sort((a, b) => b.Weight.CompareTo(a.Weight));
 }