/// <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(); }