internal void ReadXml(XmlReader reader, Type type, TypeTable table) { var relation = Relation.OneToOne; var storage = string.Empty; var viewOnly = false; RelationHierarchy? relationHierarchy = null; while (reader.MoveToNextAttribute()) { switch (reader.Name) { case XmlConstants.TypeRelation.RELATION: relation = (reader.Value == XmlConstants.TypeRelation.ONE_TO_ONE) ? Relation.OneToOne : Relation.OneToMany; break; case XmlConstants.TypeRelation.HIERARCHY: relationHierarchy = (RelationHierarchy)Enum.Parse(typeof(RelationHierarchy), reader.Value, true); break; case XmlConstants.TypeRelation.STORAGE: storage = reader.Value; break; case XmlConstants.TypeRelation.VIEW_ONLY: viewOnly = bool.Parse(reader.Value); break; } } var memberInfo = GetMemberInfo(type, storage); switch (memberInfo.MemberType) { case MemberTypes.Property: var pInfo = memberInfo as PropertyInfo; if(pInfo == null) break; ObjectType = pInfo.PropertyType; break; case MemberTypes.Field: var fInfo = memberInfo as FieldInfo; if(fInfo == null) break; ObjectType = fInfo.FieldType; break; } Relation = relation; Hierarchy = relationHierarchy; MemberName = storage; ViewOnly = viewOnly; m_memberInfo = memberInfo; if(reader.IsEmptyElement) return; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == XmlConstants.TypeRelation.REFERENCE) { var source = reader.GetAttribute(XmlConstants.TypeRelation.SOURCE_KEY); //var reference = reader.GetAttribute(Constants.TypeRelation.REFERENCE_KEY); var parentColumn = table.FirstOrDefault(col => col.Name == source); if(Equals(parentColumn, null)) throw new Exception(string.Format("Property {0} not found in type {1}", source, table.MappedObjectType.FullName)); SourceColumns.Add(parentColumn); } if ((reader.NodeType == XmlNodeType.EndElement && (reader.Name == XmlConstants.ASSOCIATION || reader.Name == XmlConstants.ASSOCIATIONS)) || reader.NodeType == XmlNodeType.Element && reader.Name == XmlConstants.ASSOCIATION) break; } }