Exemple #1
0
        internal static IEnumerable <Lazy <object> > CheckAndRetrieveCompositionConstructorArgs(IComposer composer, MemberInfo memberInfo)
        {
            // If the member is not a composition constructor, ignore the member

            if (!(memberInfo is ConstructorInfo))
            {
                return(null);
            }

            if (!HasCompositionConstructorAttribute((ConstructorInfo)memberInfo))
            {
                return(null);
            }

            // Extract parameter information from the member, and set them
            // as the parameters of ther constructor for creating the component

            var parameterInfos = ((ConstructorInfo)memberInfo).GetParameters();
            var compositionConstructorAttribute = GetCompositionConstructorAttribute(memberInfo);

            return(parameterInfos.Select((parameterInfo, index) =>
                                         composer.LazyGetComponent(parameterInfo.ParameterType,
                                                                   compositionConstructorAttribute.Names != null &&
                                                                   index < compositionConstructorAttribute.Names.Length
                                                                                                                                        ? compositionConstructorAttribute.Names[index]
                                                                                                                                        : null)));
        }