/// <summary> /// Registers a singleton with an already instantiated implementation.<br/> /// the <em>Resolve<TDependency>(TDependency implementation)</em> method /// will always return that instance. /// </summary> /// <typeparam name="TDependency">The dependency interface / base class</typeparam> /// <param name="implementation">The implementation instance to use</param> public static void Singleton <TDependency>(TDependency implementation) where TDependency : class { singletons[typeof(TDependency)] = new SingletonDependencyData { ImplementationType = implementation.GetType(), Instance = implementation }; }
/// <summary> /// Registered a singleton for TDependency using TImplementation implementation.<br/> /// The first time the <em>Resolve<TDependency, TImplementation>()</em> method /// is used for that dependency it will create a new instance. All following calls /// will return the same instance. /// </summary> /// <typeparam name="TDependency">The dependency interface / base class</typeparam> /// <typeparam name="TImplementation">The implementation class</typeparam> public static void Singleton <TDependency, TImplementation>() where TDependency : class where TImplementation : TDependency { singletons[typeof(TDependency)] = new SingletonDependencyData { ImplementationType = typeof(TImplementation) }; }