예제 #1
0
            private void AddImplicitTypes(Type boundType, SetShim <Type> implicitTypes)
            {
                lock (syncLock) {
                    foreach (Type implicitType in implicitTypes)
                    {
                        if (GetIfImplementedBy(implicitType) == null)
                        {
                            SetShim <Type> newSet, oldSet;

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

                            newSet.Add(boundType);
                            implicitTypeLookup.Add(implicitType, newSet);
                        }
                        else
                        {
                            BindImplicit(implicitType);
                        }
                    }
                }
            }
        /// <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?
                }
            }
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets the implicit types.
        /// </summary>
        /// <returns>The implicit types.</returns>
        /// <param name="boundType">Bound type.</param>
        protected internal static SetShim <Type> GetImplicitTypes(Type boundType)
        {
            var implicitTypes = new SetShim <Type>();

            foreach (Type iFace in boundType.GetInterfaces())
            {
                implicitTypes.Add(iFace);
            }

            Type wTypeChain = boundType;

            while ((wTypeChain = wTypeChain.BaseType) != null && wTypeChain != typeof(object))
            {
                implicitTypes.Add(wTypeChain);
            }

            return(implicitTypes);
        }
        /// <summary>
        /// Gets the implicit types.
        /// </summary>
        /// <returns>The implicit types.</returns>
        /// <param name="boundType">Bound type.</param>
        private static SetShim <BindingKey> GetImplicitTypes(BindingKey bindingKey)
        {
            var implicitTypes = new SetShim <BindingKey>();
            var bindingType   = bindingKey.BindingType;

            foreach (Type iFace in bindingType.GetInterfaces())
            {
                implicitTypes.Add(BindingKey.Get(iFace));
            }

            Type wTypeChain = bindingType;

            while ((wTypeChain = wTypeChain.BaseType) != null && wTypeChain != typeof(object))
            {
                implicitTypes.Add(BindingKey.Get(wTypeChain));
            }

            return(implicitTypes);
        }
예제 #5
0
            public Expression GetResolveExpression(SetShim <Type> callerDeps)
            {
                lock (syncLock) {
                    Expression <Func <CType> > expr;
                    if (singleton)
                    {
                        var instance = DoResolveTyped();
                        expr = () => instance;
                    }
                    else
                    {
                        if (!isVerifiedNotRecursive)
                        {
                            DoResolveTyped();
                        }
                        expr = resolverExpression;
                    }

                    callerDeps.UnionWith(dependencies);
                    callerDeps.Add(bindType);

                    return(expr.Body);
                }
            }