public TypeMapping(Type type, string name, UserTypeAttributes attributes) { if (type == null) throw new ArgumentNullException("type"); if (type.IsInterface) throw new ArgumentException("Interface mappings are not supported."); this.name = name; this.type = type; this.attributes = attributes; }
public TypeMapping(Type type, UserTypeAttributes attributes) : this(type, type.Name, attributes) { }
internal static TypeMapping FromType(Type type) { UserTypeAttributes attributes = new UserTypeAttributes(); if (type.IsSealed) attributes |= UserTypeAttributes.Sealed; else if (type.IsAbstract) attributes |= UserTypeAttributes.Abstract; TypeMapping typeMapping = new TypeMapping(type, attributes); MemberInfo[] memberInfos = type.FindMembers(global::System.Reflection.MemberTypes.Field | global::System.Reflection.MemberTypes.Property, BindingFlags.Instance | BindingFlags.Public, new MemberFilter(FilterMember), null); for (int i = 0; i < memberInfos.Length; i++) { TypeAttributeMapping mapping = TypeAttributeMapping.FromMember(typeMapping, memberInfos[i]); if (typeMapping.memberMappings == null) typeMapping.memberMappings = new ArrayList(); typeMapping.memberMappings.Add(mapping); } return typeMapping; }