//public XDependencyProperty() //{ //} private XDependencyProperty( Type ownerType, string name, Type propertyType) { _OwnerType = ownerType; _Name = name; _PropertyType = propertyType; _DefaultValue = ValueTypeHelper.GetDefaultValue(_PropertyType); }
/// <summary> /// 注册属性 /// </summary> /// <param name="name">属性名</param> /// <param name="propertyType">属性数据类型</param> /// <param name="ownerType">属性所属对象类型</param> /// <returns>属性注册对象</returns> public static XDependencyProperty Register( string name, Type propertyType, Type ownerType) { if (name == null || name.Trim().Length == 0) { throw new ArgumentNullException("name"); } name = name.Trim(); if (propertyType == null) { throw new ArgumentNullException("propertyType"); } if (ownerType == null) { throw new ArgumentNullException("ownerType"); } Dictionary <string, XDependencyProperty> table = null; if (_PropertiyTable.ContainsKey(ownerType)) { table = _PropertiyTable[ownerType]; } else { table = new Dictionary <string, XDependencyProperty>(); _PropertiyTable[ownerType] = table; } if (table.ContainsKey(name)) { throw new ArgumentException("Multi " + name); } XDependencyProperty property = new XDependencyProperty( ownerType, name, propertyType); property.DefaultValue = ValueTypeHelper.GetDefaultValue(propertyType); table[name] = property; return(property); }