/// <summary> /// Initializes a new instance of the <see cref="NaturalKey"/> class. /// </summary> /// <param name="runtimeType">The runtime type.</param> /// <param name="propertyName">The property name.</param> /// <param name="propertyType">The property type.</param> /// <param name="typeAnalyzerService">The type analyzer service.</param> //// TODO (Cameron): Should there be another overload? public NaturalKey(Type runtimeType, string propertyName, Type propertyType, ITypeAnalyzerService typeAnalyzerService) : base(DefaultEqualityComparer) { Guard.Against.Null(() => runtimeType); Guard.Against.Null(() => propertyName); // TODO (Cameron): Or empty! Guard.Against.Null(() => propertyType); Guard.Against.Null(() => typeAnalyzerService); if (!typeAnalyzerService.IsValidEntity(runtimeType)) { throw new BusinessException( string.Format(CultureInfo.InvariantCulture, "The specified runtime type '{0}' is not an entity.", runtimeType)); } if (!typeAnalyzerService.IsValidProperty(runtimeType, propertyName, propertyType)) { throw new BusinessException( string.Format( CultureInfo.InvariantCulture, "Invalid natural key specification. The entity '{0}' does not contain a property named '{1}' of type '{2}'.", runtimeType, propertyName, propertyType)); } this.PropertyName = propertyName; this.PropertyType = propertyType; this.RuntimeType = runtimeType; this.getValue = AssignGetValue(runtimeType, propertyName); }
public EntityConfigurationWrapper(EntityType entityType, ITypeAnalyzerService typeAnalyzerService) { Guard.Against.Null(() => entityType); Guard.Against.Null(() => typeAnalyzerService); this.entityType = entityType; this.typeAnalyzerService = typeAnalyzerService; }
public ValueObjectTypeFactory(ITypeAnalyzerService typeAnalyzerService, IBootstrapperProvider bootstrapperProvider) { Guard.Against.Null(() => typeAnalyzerService); Guard.Against.Null(() => bootstrapperProvider); this.typeAnalyzerService = typeAnalyzerService; this.bootstrapperProvider = bootstrapperProvider; }
public EntityTypeFactory(ITypeAnalyzerService typeAnalyzerService, IBootstrapperProvider bootstrapperProvider) { Guard.Against.Null(() => typeAnalyzerService); Guard.Against.Null(() => bootstrapperProvider); this.typeAnalyzerService = typeAnalyzerService; this.bootstrapperProvider = bootstrapperProvider; }
public BootstrapperConfiguration(ValueObjectType valueObjectType, ITypeAnalyzerService typeAnalyzerService) { Guard.Against.Null(() => valueObjectType); Guard.Against.Null(() => typeAnalyzerService); this.valueObjectType = valueObjectType; this.typeAnalyzerService = typeAnalyzerService; }
public BootstrapperConfiguration(AggregateRootType aggregateRootType, ITypeAnalyzerService typeAnalyzerService) { Guard.Against.Null(() => aggregateRootType); Guard.Against.Null(() => typeAnalyzerService); this.aggregateRootType = aggregateRootType; this.entityType = aggregateRootType; this.typeAnalyzerService = typeAnalyzerService; }
/// <summary> /// Initializes a new instance of the <see cref="AggregateRootType"/> class. /// </summary> /// <param name="runtimeType">The runtime type.</param> /// <param name="typeAnalyzerService">The type analyzer service.</param> /// <param name="baseEntity">The base entity.</param> public AggregateRootType(Type runtimeType, ITypeAnalyzerService typeAnalyzerService, EntityType baseEntity) : base(runtimeType, typeAnalyzerService, baseEntity) { Guard.Against.Null(() => runtimeType); Guard.Against.Null(() => typeAnalyzerService); if (!typeAnalyzerService.IsValidAggregateRoot(runtimeType)) { throw new BusinessException( string.Format(CultureInfo.InvariantCulture, "The specified runtime type '{0}' is not an aggregate root.", runtimeType)); } // NOTE (Cameron): Defaults. this.EventDispatcher = new DefaultEventDispatcher(runtimeType); }
/// <summary> /// Initializes a new instance of the <see cref="EntityType"/> class. /// </summary> /// <param name="runtimeType">The runtime type.</param> /// <param name="typeAnalyzerService">The type analyzer service.</param> public EntityType(Type runtimeType, ITypeAnalyzerService typeAnalyzerService) : base(new NaturalKey(typeof(EntityType), "RuntimeType", typeof(Type), DefaultTypeAnalyzerService)) { Guard.Against.Null(() => runtimeType); Guard.Against.Null(() => typeAnalyzerService); if (!typeAnalyzerService.IsValidEntity(runtimeType)) { throw new BusinessException( string.Format(CultureInfo.InvariantCulture, "The specified runtime type '{0}' is not an entity.", runtimeType)); } this.RuntimeType = runtimeType; this.entityNaturalKey = typeAnalyzerService.GetNaturalKey(runtimeType); this.Mappings = new MapperCollection(); }
/// <summary> /// Initializes a new instance of the <see cref="ValueObjectType"/> class. /// </summary> /// <param name="runtimeType">The runtime type.</param> /// <param name="typeAnalyzerService">The type analyzer service.</param> public ValueObjectType(Type runtimeType, ITypeAnalyzerService typeAnalyzerService) : base(new NaturalKey(typeof(ValueObjectType), "RuntimeType", typeof(Type), DefaultTypeAnalyzerService)) { Guard.Against.Null(() => runtimeType); Guard.Against.Null(() => typeAnalyzerService); if (!typeAnalyzerService.IsValidValueObject(runtimeType)) { throw new BusinessException( string.Format(CultureInfo.InvariantCulture, "The specified runtime type '{0}' is not a value object.", runtimeType)); } this.RuntimeType = runtimeType; this.EqualityComparer = Activator.CreateInstance(typeof(DefaultValueObjectEqualityComparer <>).MakeGenericType(runtimeType)); this.Serializer = (IValueObjectSerializer)Activator.CreateInstance(typeof(DefaultValueObjectSerializer <>).MakeGenericType(runtimeType)); this.Mappings = new MapperCollection(); }
/// <summary> /// Initializes a new instance of the <see cref="EntityType"/> class. /// </summary> /// <param name="runtimeType">Type of the runtime.</param> /// <param name="entityAnalyzerService">The entity analyzer service.</param> /// <param name="baseEntity">The base entity.</param> public EntityType(Type runtimeType, ITypeAnalyzerService entityAnalyzerService, EntityType baseEntity) : this(runtimeType, entityAnalyzerService) { Guard.Against.Null(() => runtimeType); Guard.Against.Null(() => baseEntity); if (baseEntity.RuntimeType != runtimeType.BaseType) { throw new BusinessException( string.Format( CultureInfo.InvariantCulture, "The specified base entity runtime type '{0}' does not match the runtime type base type '{1}'.", baseEntity.RuntimeType, runtimeType.BaseType)); } this.baseEntityNaturalKey = baseEntity.NaturalKey; }
private static ValueObjectType CreateValueObjectType(ITypeAnalyzerService typeAnalyzerService, IBootstrapperProvider bootstrapperProvider, Type type) { return(new ValueObjectTypeFactory(typeAnalyzerService, bootstrapperProvider).Create(type)); }