public IEnumerable <ISerializeProperty> GetSerializPropertyList() { var result = new List <ISerializeProperty>(); if (_type == null) { return(result); } _type.EnumerateAttributes <SerializePropertyAttribute, string>(o => { var pd = TryToGetDependencyProperty(_type, o.BindPath) ?? _properties[o.BindPath]; if (pd == null) { return; } TypeConverter converter = null; if (o.Converter != null) { converter = CreateInstance(o.Converter, pd.PropertyType) as TypeConverter; } if (converter == null) { converter = TypeDescriptor.GetConverter(pd.PropertyType); } result.Add(SerializePropertyImpl.Create(_type, pd, converter)); }, null); _type.EnumeratePropertiesAttributes <SerializableAttribute>((pro, da) => { result.Add(SerializePropertyImpl.Create(_type, pro, pro.Converter)); }); return(result); }
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); }