/// <summary> /// Registers a typed factory. /// </summary> /// <param name="containerBuilder"> /// The Unity container. /// </param> /// <param name="factoryContractType"> /// The factory interface. /// </param> /// <returns> /// The holder object which facilitates the fluent interface. /// </returns> /// <exception cref="ArgumentException"> /// Thrown when the <paramref name="factoryContractType"/> does not represent an interface type. /// </exception> public static ITypedFactoryRegistration RegisterTypedFactory(this ContainerBuilder containerBuilder, Type factoryContractType) { if (!factoryContractType.IsInterface) { throw new ArgumentException("The factory contract does not represent an interface!", "factoryContractType"); } var typedFactoryRegistration = new TypedFactoryRegistration(containerBuilder, factoryContractType); return(typedFactoryRegistration); }
/// <summary> /// Registers a typed factory. /// </summary> /// <typeparam name="TFactory"> /// The factory interface. /// </typeparam> /// <param name="containerBuilder"> /// The Unity container. /// </param> /// <returns> /// The holder object which facilitates the fluent interface. /// </returns> public static ITypedFactoryRegistration RegisterTypedFactory <TFactory>(this ContainerBuilder containerBuilder) where TFactory : class { if (!typeof(TFactory).IsInterface) { throw new ArgumentException("The factory contract does not represent an interface!"); } var typedFactoryRegistration = new TypedFactoryRegistration <TFactory>(containerBuilder); return(typedFactoryRegistration); }
/// <summary> /// Registers a typed factory. /// </summary> /// <param name="containerBuilder"> /// The Unity container. /// </param> /// <param name="factoryContractType"> /// The factory interface. /// </param> /// <param name="name"> /// Name that will be used to request the type. /// </param> /// <returns> /// The holder object which facilitates the fluent interface. /// </returns> public static ITypedFactoryRegistration RegisterTypedFactory(this ContainerBuilder containerBuilder, Type factoryContractType, string name) { var typedFactoryRegistration = new TypedFactoryRegistration(containerBuilder, factoryContractType, name); return(typedFactoryRegistration); }