/// <summary>
        /// Adds the implicit types.
        /// </summary>
        /// <param name="bindingKey">Binding key.</param>
        /// <param name="implicitTypeKeys">Implicit type keys.</param>
        private void AddImplicitTypes(BindingKey bindingKey, SetShim <BindingKey> implicitTypeKeys)
        {
            foreach (BindingKey implicitTypeKey in implicitTypeKeys)
            {
                if (BindingAttributeUtils.GetImplementedBy(implicitTypeKey.BindingType) == null)
                {
                    SetShim <BindingKey> newSet, oldSet;

                    if (implicitTypeLookup.TryGetValue(implicitTypeKey, out oldSet))
                    {
                        implicitTypeLookup.Remove(implicitTypeKey);
                        newSet = new SetShim <BindingKey> (oldSet);
                    }
                    else
                    {
                        newSet = new SetShim <BindingKey> ();
                    }

                    newSet.Add(bindingKey);
                    implicitTypeLookup.Add(implicitTypeKey, newSet);
                }
                else
                {
                    return;                     // TODO - should skip rest?
                }
            }
        }
Пример #2
0
		/// <summary>
		/// Gets the generic implementation.
		/// </summary>
		/// <returns>The generic implementation.</returns>
		/// <param name="genericBindingKey">Generic binding key.</param>
		/// <param name="genericBindingType">Generic binding type.</param>
		/// <param name="genericBindingConfig">Generic binding config.</param>
		private Type GetGenericImplementation (BindingKey genericBindingKey, Type genericBindingType, out IBindingConfig genericBindingConfig) {
			genericBindingConfig = null;

			// Try registrations
			if (allGenericResolvers.TryGetValue (genericBindingKey, out genericBindingConfig)) {
				return genericBindingConfig.ConcreteType;
			}

			// Try implicit
			return BindingAttributeUtils.GetImplementedBy (genericBindingType);
		}
Пример #3
0
        private IResolver BindImplicit(BindingKey bindingKey)
        {
            lock (syncLock) {
                IResolver resolver;
                if (allResolvers.TryGetValue(bindingKey, out resolver))
                {
                    return(resolver);
                }

                Type implType = BindingAttributeUtils.GetImplementedBy(bindingKey.BindingType);

                return(CreateResolverInstanceGeneric(
                           bindingKey.ToImplicit(),
                           (implType != null) ? implType : bindingKey.BindingType));
            }
        }