Ejemplo n.º 1
0
        internal static TypeAttributeMapping FromMember(TypeMapping declaringType, MemberInfo memberInfo)
        {
            string name = null;
            SqlType sqlType = GetSqlType(memberInfo);
            int size = -1;
            int scale = -1;
            bool nullable = true;

            object[] attrs = memberInfo.GetCustomAttributes(true);
            for (int i = 0; i < attrs.Length; i++) {
                object attr = attrs[i];

                if (attr is ColumnAttribute) {
                    ColumnAttribute columnAttr = (ColumnAttribute)attr;
                    name = columnAttr.ColumnName;
                    sqlType = columnAttr.SqlType;
                    size = columnAttr.Size;
                    scale = columnAttr.Scale;
                } else if (attr is NotNullAttribute) {
                    nullable = false;
                }
            }

            TType type = GetTType(sqlType, size, scale);

            return new TypeAttributeMapping(declaringType, name, type, nullable);
        }
Ejemplo n.º 2
0
 internal MemberMapping(TypeMapping typeMapping, string memberName, string columnName, SqlType columnType, bool notNull)
 {
     TypeMapping = typeMapping;
     MemberName = memberName;
     ColumnName = columnName;
     ColumnType = columnType;
     NotNull = notNull;
 }
Ejemplo n.º 3
0
 internal MemberMapping(TypeMapping typeMapping, MemberInfo member, string columnName, SqlType columnType, bool notNull, bool primaryKey, bool unique, bool uniqueKey)
 {
     TypeMapping = typeMapping;
     Member = member;
     ColumnName = columnName;
     ColumnType = columnType;
     NotNull = notNull;
     PrimaryKey = primaryKey;
     Unique = unique;
     UniqueKey = uniqueKey;
 }
Ejemplo n.º 4
0
 internal TypeAttributeMapping(TypeMapping declaringType, string memberName, TType type, bool nullable)
     : base(declaringType, memberName)
 {
     this.type = type;
     this.nullable = nullable;
 }
Ejemplo n.º 5
0
 internal void Map(TypeMapping mapping)
 {
     typeMappings[mapping.Type] = mapping;
 }
Ejemplo n.º 6
0
 public object Clone()
 {
     TypeMapping mapping = new TypeMapping(type, (string)name.Clone(), attributes);
     if (memberMappings != null)
         mapping.memberMappings = (ArrayList) memberMappings.Clone();
     return mapping;
 }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
 internal TypeMemberMapping(TypeMapping dtype, string name)
 {
     this.name = name;
     this.dtype = dtype;
 }
Ejemplo n.º 9
0
 public DbMappingEntity(string tableId, TypeMapping typeMapping)
 {
     this.tableId = tableId;
     TypeMapping = typeMapping;
 }