Exemple #1
0
        public void TestGetReflectionBasedCreationFunction()
        {
            ValidateFunc <TestSimpleClass>(ObjectInstantiationHelper.GetReflectionBasedCreationFunction(typeof(TestSimpleClass), null));
            ValidateFunc <TestClassWithConstructor>(ObjectInstantiationHelper.GetReflectionBasedCreationFunction(typeof(TestClassWithConstructor), null));
            var v3 = ValidateFunc <TestClassWithMarkedConstructor>(ObjectInstantiationHelper.GetReflectionBasedCreationFunction(typeof(TestClassWithMarkedConstructor), null));

            Assert.AreEqual(10, v3.Val);
        }
        /// <summary>
        /// Creates a DeferedSingletonLifetime container that resolves an instance of the specified object type
        /// </summary>
        /// <param name="objType">The type of the object that will be held by the lifetime container</param>
        /// <param name="injection">Injection resolver that will be used to create an instance if required</param>
        /// <param name="extInfo">Extended information supplied by the user (can be null)</param>
        /// <returns>Created lifetime container for the specified object type</returns>
        public override LifetimeBase Create(Type objType, IInjectionResolver injection, object extInfo)
        {
            if (objType == null)
            {
                throw new ArgumentNullException(nameof(objType));
            }
            if (injection == null)
            {
                throw new ArgumentNullException(nameof(injection));
            }

            var creationFunc = ObjectInstantiationHelper.GetReflectionBasedCreationFunction(objType, extInfo);

            return(new DeferedSingletonLifetime(creationFunc, objType));
        }
Exemple #3
0
        /// <summary>
        /// Creates a DeferedSingletonLifetime container that resolves an instance of the specified object type
        /// </summary>
        /// <param name="objType">The type of the object that will be held by the lifetime container</param>
        /// <param name="injection">Injection resolver that will be used to create an instance if required</param>
        /// <param name="extInfo">Extended information supplied by the user (can be null)</param>
        /// <returns>Created lifetime container for the specified object type</returns>
        public override LifetimeBase Create(Type objType, IInjectionResolver injection, object extInfo)
        {
            var creationFunc = ObjectInstantiationHelper.GetReflectionBasedCreationFunction(objType, extInfo);

            return(new DeferedSingletonLifetime(creationFunc, objType));
        }