예제 #1
0
        private void CreateInstanceProvider(MethodBase method, ProviderAttribute providerAttribute, bool isSingleton)
        {
            InjectionProvider provider = isSingleton
                ? new SingletonInjectionProvider(method)
                : new InjectionProvider(method);

            if (providerAttribute.Name != null)
            {
                this.namedProviderMap.Add(providerAttribute.Name, provider);
            }

            if (providerAttribute.ProvidesType != null)
            {
                this.providerMap.Add(providerAttribute.ProvidesType, provider);
            }
        }
예제 #2
0
        private void CreateSetProvider(MethodBase method, ProviderAttribute providesSetAttribute, bool isSingleton)
        {
            InjectionProvider    mappedProvider;
            SetInjectionProvider setProvider = null;

            if (providesSetAttribute.Name != null)
            {
                if (this.namedProviderMap.TryGetValue(providesSetAttribute.Name, out mappedProvider))
                {
                    setProvider = mappedProvider as SetInjectionProvider;
                }
                else
                {
                    setProvider = new SetInjectionProvider();
                    this.namedProviderMap.Add(providesSetAttribute.Name, setProvider);
                }
            }

            if (providesSetAttribute.ProvidesType != null)
            {
                if (this.providerMap.TryGetValue(providesSetAttribute.ProvidesType, out mappedProvider))
                {
                    setProvider = mappedProvider as SetInjectionProvider;
                }
                else
                {
                    setProvider = new SetInjectionProvider();
                    this.providerMap.Add(providesSetAttribute.ProvidesType, setProvider);
                }
            }

            if (setProvider != null)
            {
                InjectionProvider provider = isSingleton
                    ? new SingletonInjectionProvider(method)
                    : new InjectionProvider(method);
                setProvider.AddProvider(provider);
            }
        }
예제 #3
0
 public void AddProvider(InjectionProvider provider)
 {
     this.providerList.Add(provider);
 }