internal TypeRelation(Relation relation, Type objectType, string memberName, string sourceKey, string referenceKey, MemberInfo memberInfo, TypeColumn sourceKeyColumn) { Relation = relation; ObjectType = objectType; MemberName = memberName; SourceKey = sourceKey; ReferenceKey = referenceKey; SourceKeyColumn = sourceKeyColumn; m_memberInfo = memberInfo; }
internal void ReadXml(XmlReader reader, Type type, TypeTable table) { var relation = Relation.OneToOne; var storage = string.Empty; var sourcekey = string.Empty; var refkey = string.Empty; var viewOnly = false; while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "Relation": relation = (reader.Value == "OneToOne") ? Relation.OneToOne : Relation.OneToMany; break; case "Storage": storage = reader.Value; break; case "SourceKey": sourcekey = reader.Value; break; case "ReferenceKey": refkey = reader.Value; break; case "ViewOnly": 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; MemberName = storage; SourceKey = sourcekey; ReferenceKey = refkey; ViewOnly = viewOnly; m_memberInfo = memberInfo; var column = table.First(col => col.Name == SourceKey); if (column != null) { SourceKeyColumn = column; } }