internal ObjectInfo(object receiver, Type type, string modelName) : this() { IsObjectContext = Attribute.GetCustomAttribute(type, typeof(ObjectContextAttribute), false) != null; // 扫描对象的每个属性,根据属性所标注的特性,配置Attribute,Content和Element子项 PropertyInfo[] properties = type.GetProperties(BIND_ATTRIBUTE); foreach (var property in properties) { object[] propertyAttributes = property.GetCustomAttributes(false); if (propertyAttributes.Length == 0) { continue; } var attribute = (from attr in propertyAttributes where attr is SimpleAttributeAttribute select attr).FirstOrDefault(); if (attribute != null) { SimpleAttributeAttribute simpleAttr = attribute as SimpleAttributeAttribute; simpleAttr.SetNameMode(modelName, property); ObjectPropertyInfo attrInfo = new ReflectorObjectPropertyInfo( property, simpleAttr, modelName); fAttributes.Add(attrInfo.QName.LocalName, attrInfo); continue; } attribute = (from attr in propertyAttributes where (attr is TextContentAttribute || attr is ComplexContentAttribute) select attr).FirstOrDefault(); if (attribute != null) { AssertContent(receiver, type, fContent); fContent = new ReflectorObjectPropertyInfo(property, attribute as BaseObjectAttribute, modelName); continue; } attribute = (from attr in propertyAttributes where attr is TagElementAttribute select attr).FirstOrDefault(); if (attribute != null) { TagElementAttribute tagAttr = attribute.Convert <TagElementAttribute>(); tagAttr.SetNameMode(modelName, property); fElements.Add(type, property, tagAttr, modelName); tagAttr.Read(type, property, modelName, propertyAttributes); continue; } fElements.ReadElementAttribute(type, property, modelName, propertyAttributes); } }
internal void Read(Type type, PropertyInfo property, string modelName, object[] propertyAttributes) { fChildElements.ReadElementAttribute(type, property, modelName, propertyAttributes); }