Esempio n. 1
0
        private static ConstructorInjectionData CreateConstructorInjectionData(Type type, ConstructorInfo constructorInfo)
        {
            ParameterInfo[] parameterInfos = constructorInfo.GetParameters();
            object[]        injectionKeys  = new object[parameterInfos.Length];
            foreach (ParameterInfo parameterInfo in parameterInfos)
            {
                object injectionKey   = GetInjectionKey(parameterInfo);
                int    parameterIndex = parameterInfo.Position;
                injectionKeys[parameterIndex] = injectionKey;
            }
            ConstructorInjectionData result = new ConstructorInjectionData(type, injectionKeys);

            return(result);
        }
Esempio n. 2
0
        internal object[] GetValuesForConstructorInjection(Type type)
        {
            if (getValuesForConstructorInjectionVisitedTypes.Contains(type))
            {
                throw new CyclicConstructorDependenciesException($"Circular dependencies in the constructor parameters of type {type}");
            }
            getValuesForConstructorInjectionVisitedTypes.Add(type);

            ConstructorInjectionData constructorInjectionData = UniInjectUtils.GetConstructorInjectionData(type);

            object[] injectionKeys = constructorInjectionData.InjectionKeys;
            object[] result        = GetValuesForInjectionKeys(injectionKeys);

            getValuesForConstructorInjectionVisitedTypes.Remove(type);
            return(result);
        }