コード例 #1
0
        /// <summary>
        /// Attempts to add a new association to the container. Lifetime factory used to create a specific lifetime container.
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="objType">The type of the object that will be held by the lifetime container</param>
        /// <param name="val">Factory to create a lifetime container for the sepcified 'objType'</param>
        /// <returns>True if AssociationContainer not contains lifetime container with the same key; overwise false</returns>
        protected bool TryAddAssociation(TKey key, Type objType, Qoollo.Turbo.IoC.Lifetime.Factories.LifetimeFactory val)
        {
            Contract.Requires(key != null);
            Contract.Requires(objType != null);
            Contract.Requires(val != null);
            Contract.Ensures(Contract.Result <bool>() == false || this.ContainsInner(key));

            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (objType == null)
            {
                throw new ArgumentNullException("objType");
            }
            if (val == null)
            {
                throw new ArgumentNullException("val");
            }

            if (!IsGoodTypeForKey(key, objType))
            {
                throw new AssociationBadKeyForTypeException(string.Format("Bad key ({0}) for the type ({1})", key, objType));
            }

            CheckContainerState(true);

            return(TryAddAssociationInner(key, objType, val));
        }
コード例 #2
0
        /// <summary>
        /// Adds a new association to the container. Lifetime factory used to create a specific lifetime container.
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="objType">The type of the object that will be held by the lifetime container</param>
        /// <param name="val">Factory to create a lifetime container for the sepcified 'objType'</param>
        protected void AddAssociation(TKey key, Type objType, Qoollo.Turbo.IoC.Lifetime.Factories.LifetimeFactory val)
        {
            TurboContract.Requires(key != null, conditionString: "key != null");
            TurboContract.Requires(objType != null, conditionString: "objType != null");
            TurboContract.Requires(val != null, conditionString: "val != null");
            TurboContract.Ensures(this.ContainsInner(key));

            if (!IsGoodTypeForKey(key, objType))
            {
                throw new AssociationBadKeyForTypeException(string.Format("Bad key ({0}) for the type ({1})", key, objType));
            }

            CheckContainerState(true);

            AddAssociationInner(key, objType, val);
        }
コード例 #3
0
 /// <summary>
 /// Attempts to add a new association to the container. Should be implemented in derived type.
 /// </summary>
 /// <param name="key">Key</param>
 /// <param name="objType">The type of the object that will be held by the lifetime container</param>
 /// <param name="val">Factory to create a lifetime container for the sepcified 'objType'</param>
 /// <returns>True if AssociationContainer not contains lifetime container with the same key; overwise false</returns>
 protected abstract bool TryAddAssociationInner(TKey key, Type objType, Qoollo.Turbo.IoC.Lifetime.Factories.LifetimeFactory val);