/// <summary> /// Adds a lifetime object container for the specified key /// </summary> /// <typeparam name="TSrc">The type that will be used as a key</typeparam> /// <param name="obj">Association container to which the addition is performed</param> /// <param name="lifetimeContainer">Lifetime object container to add</param> public static void AddAssociation <TSrc>(this ICustomAssociationSupport <Type> obj, Lifetime.LifetimeBase lifetimeContainer) { Contract.Requires(obj != null); Contract.Requires <ArgumentNullException>(lifetimeContainer != null); obj.AddAssociation(typeof(TSrc), lifetimeContainer); }
/// <summary> /// Adds a lifetime object container for the specified key /// </summary> /// <typeparam name="TSrc">The type that will be used as a key</typeparam> /// <param name="obj">Association container to which the addition is performed</param> /// <param name="lifetimeContainer">Lifetime object container to add</param> public static void AddAssociation <TSrc>(this ICustomAssociationSupport <Type> obj, Lifetime.LifetimeBase lifetimeContainer) { TurboContract.Requires(obj != null, conditionString: "obj != null"); TurboContract.Requires(lifetimeContainer != null, conditionString: "lifetimeContainer != null"); obj.AddAssociation(typeof(TSrc), lifetimeContainer); }
/// <summary> /// Attempts to add a lifetime object container created by the 'factory' for the specified key /// </summary> /// <typeparam name="TSrc">The type that will be used as a key</typeparam> /// <param name="obj">Association container to which the addition is performed</param> /// <param name="objType">The type of the object that will be held by the lifetime container</param> /// <param name="factory">Factory to create a lifetime container for the sepcified 'objType'</param> /// <returns>True if the association was added successfully (that is AssociationContainer did not contained lifetime container with the same key); overwise false</returns> public static bool TryAddAssociation <TSrc>(this ICustomAssociationSupport <Type> obj, Type objType, Lifetime.Factories.LifetimeFactory factory) { Contract.Requires(obj != null); Contract.Requires <ArgumentNullException>(objType != null); Contract.Requires <ArgumentNullException>(factory != null); return(obj.TryAddAssociation(typeof(TSrc), objType, factory)); }
/// <summary> /// Attempts to add a lifetime object container created by the 'factory' for the specified key /// </summary> /// <typeparam name="TSrc">The type that will be used as a key</typeparam> /// <param name="obj">Association container to which the addition is performed</param> /// <param name="objType">The type of the object that will be held by the lifetime container</param> /// <param name="factory">Factory to create a lifetime container for the sepcified 'objType'</param> /// <returns>True if the association was added successfully (that is AssociationContainer did not contained lifetime container with the same key); overwise false</returns> public static bool TryAddAssociation <TSrc>(this ICustomAssociationSupport <Type> obj, Type objType, Lifetime.Factories.LifetimeFactory factory) { TurboContract.Requires(obj != null, conditionString: "obj != null"); TurboContract.Requires(objType != null, conditionString: "objType != null"); TurboContract.Requires(factory != null, conditionString: "factory != null"); return(obj.TryAddAssociation(typeof(TSrc), objType, factory)); }