/// <summary> /// Registers a type using a specified type as target /// </summary> /// <typeparam name="TFor">Type to register for</typeparam> /// <typeparam name="TTo">Type to register to</typeparam> /// <param name="name">Name of the registration</param> public void Register <TFor, TTo>(string name = null) where TFor : class where TTo : class { var fac = this.constructorFactory.Create <TTo>(); this.factories.TryAdd(FactoryIndex.Create <TFor>(name), fac); }
/// <summary> /// Registers a type factory for the specified name and type /// </summary> /// <typeparam name="T">Type to register</typeparam> /// <param name="factory">Factory method to use when the type is resolved</param> /// <param name="name">Name of the registration</param> public void Register <T>(Func <IDependencyResolver, T> factory, string name) where T : class { this.factories.TryAdd(FactoryIndex.Create <T>(name), factory); }
/// <summary> /// Registers an instance of type T with the specified name /// </summary> /// <typeparam name="T">Type to register</typeparam> /// <param name="instance">Instane to register for the specified type</param> /// <param name="name">Name to use for the registration</param> public void Register <T>(T instance, string name) where T : class { this.factories.TryAdd(FactoryIndex.Create <T>(name), ir => instance); }