Exemple #1
0
        public void RegisterScoped <T>(string name = null, Func <T> factory = null) where T : class
        {
            var dependency = new RegisteredDependency(typeof(T), Lifestyle.Scoped, factory as Func <object>);

            dependencyDictionary.Add(name ?? typeof(T).Name, dependency);
        }
Exemple #2
0
        public void RegisterSingleton <TInterface, TImplementation>(string name = null, Func <TInterface> factory = null) where TImplementation : class, TInterface
        {
            var dependency = new RegisteredDependency(typeof(TImplementation), typeof(TInterface), Lifestyle.Singleton, factory as Func <object>);

            dependencyDictionary.Add(name ?? typeof(TInterface).Name + typeof(TImplementation).Name, dependency);
        }
Exemple #3
0
        public void RegisterInstance <T>(T singletonInstance) where T : class
        {
            var dependency = new RegisteredDependency(typeof(T), singletonInstance);

            dependencyDictionary.Add(typeof(T).Name, dependency);
        }
Exemple #4
0
        public void RegisterSingleton <TInterface, TImplementation>(TInterface singletonInstance, string name = null) where TImplementation : class, TInterface
        {
            var dependency = new RegisteredDependency(typeof(TImplementation), typeof(TInterface), singletonInstance);

            dependencyDictionary.Add(name ?? typeof(TInterface).Name + typeof(TImplementation).Name, dependency);
        }
Exemple #5
0
 private object ResolveRegisteredDependency(string name, RegisteredDependency registeredDependency) => registeredDependency.Lifestyle switch
 {