internal FieldDef(Type valueType, Validator validator) { this.validator = validator; IsStructure = valueType.IsSubclassOf(WellKnownOrmTypes.Structure) || valueType == WellKnownOrmTypes.Structure; IsEntity = WellKnownOrmInterfaces.Entity.IsAssignableFrom(valueType); if ((valueType.IsClass || valueType.IsInterface) && !IsStructure) { attributes |= FieldAttributes.Nullable; } ValueType = valueType; Validators = new List <IPropertyValidator>(); // Nullable<T> if (valueType.IsNullable()) { attributes |= FieldAttributes.Nullable; return; } // EntitySet<TEntity> var genericTypeDefinition = valueType.GetGenericType(WellKnownOrmTypes.EntitySetOfT); if (genericTypeDefinition != null) { IsEntitySet = true; ItemType = genericTypeDefinition.GetGenericArguments()[0]; } }
internal FieldDef(Type valueType, Validator validator) { this.validator = validator; IsStructure = valueType.IsSubclassOf(typeof(Structure)) || valueType == typeof(Structure); IsEntity = typeof(IEntity).IsAssignableFrom(valueType); if ((valueType.IsClass || valueType.IsInterface) && !IsStructure) { attributes |= FieldAttributes.Nullable; } ValueType = valueType; Validators = new List <IPropertyValidator>(); // Nullable<T> if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Nullable <>)) { attributes |= FieldAttributes.Nullable; return; } // EntitySet<TEntity> var genericTypeDefinition = valueType.GetGenericType(typeof(EntitySet <>)); if (genericTypeDefinition != null) { IsEntitySet = true; ItemType = genericTypeDefinition.GetGenericArguments()[0]; } }