public static List <IModelProperty> GetModelPropertys(DependencyObject obj)
        {
            if (obj == null)
            {
                return(new List <IModelProperty>());
            }
            DesignAttributeService service = TryGetService(obj);

            if (service == null)
            {
                return(new List <IModelProperty>());
            }
            var result = service._ModelPropertyList.Select(x =>
            {
                var pro = new ModelPropertyImpl();
                pro.CopyFrom(x);
                pro.Owner = obj;
                if (pro.Binding != null)
                {
                    pro.Binding.Source = obj;
                }
                return((IModelProperty)pro);
            }).ToList();

            IDesignerChildable childable = obj as IDesignerChildable;

            if (childable != null)
            {
                result.AddRange(GetModelPropertys(childable.DesignerChild));
            }
            return(result);
        }
        public static List <IDesignProperty> GetDesignPropertys(DependencyObject dObj)//获得DesignerItem控件属性 DesignerItem外层封装了一个DesignerContainer 设计时点击控件,显示控件PropertyView时
        {
            if (dObj == null)
            {
                return(new List <IDesignProperty>());
            }
            DesignAttributeService dasvc = TryGetService(dObj);

            if (dasvc == null)
            {
                return(new List <IDesignProperty>());
            }
            List <IDesignProperty> result = dasvc._viewPropertyList.Select(o =>//将控件属性与控件依赖绑定
            {
                DesignPropertyImpl dpi = new DesignPropertyImpl();
                dpi.CopyFrom(o);
                dpi.Owner          = dObj;
                dpi.Binding.Source = dObj;
                //string sss = dpi.
                return((IDesignProperty)dpi);
            }).ToList();

            IDesignerChildable childable = dObj as IDesignerChildable;

            if (childable != null)
            {
                result.AddRange(GetDesignPropertys(childable.DesignerChild));                   //递归获得DesignerContainer.Content 里面的控件的详细属性
            }
            return(result);
        }
        private static DesignAttributeService TryGetService(DependencyObject obj)//根据传过来控件的类型Type获得其属性Service
        {
            Type type = obj.GetType();

            if (!_DicDesignerServiceCache.ContainsKey(type))
            {
                _DicDesignerServiceCache[type] = new DesignAttributeService(type);
            }
            DesignAttributeService service = _DicDesignerServiceCache[type];

            return(service);
        }
        public static List <ISerializeProperty> GetSerializPropertys(DependencyObject obj)//获得序列化对象属性
        {
            if (obj == null)
            {
                return(new List <ISerializeProperty>());
            }
            DesignAttributeService dasvc = TryGetService(obj);

            if (dasvc == null)
            {
                return(new List <ISerializeProperty>());
            }
            var result = dasvc._serializPropertyList.Select(x =>
            {
                var pro = new SerializePropertyImpl();//和下面的 DesignPropertyImpl 不同
                pro.CopyFrom(x);
                pro.Owner = obj;
                //pro.guid
                return((ISerializeProperty)pro);
            }).ToList();

            return(result);
        }