private ImportDefinition TranslateImport(ReflectionImportDefinition reflectionImport, List <LazyMemberInfo> members, List <Lazy <ParameterInfo> > parameters)
        {
            bool isExportFactory = false;
            ContractBasedImportDefinition productImport = reflectionImport;

            if (reflectionImport is IPartCreatorImportDefinition exportFactoryImportDefinition)
            {
                productImport   = exportFactoryImportDefinition.ProductImportDefinition;
                isExportFactory = true;
            }

            string contractName                    = Translate(productImport.ContractName);
            string requiredTypeIdentity            = Translate(productImport.RequiredTypeIdentity !);
            IDictionary <string, object?> metadata = TranslateImportMetadata(productImport);

            ImportDefinition?import = null;

            if (reflectionImport is ReflectionMemberImportDefinition memberImport)
            {
                LazyMemberInfo lazyMember      = memberImport.ImportingLazyMember;
                LazyMemberInfo importingMember = new LazyMemberInfo(lazyMember.MemberType, () => GetAccessors(lazyMember));

                if (isExportFactory)
                {
                    import = new PartCreatorMemberImportDefinition(
                        importingMember,
                        ((ICompositionElement)memberImport).Origin,
                        new ContractBasedImportDefinition(
                            contractName,
                            requiredTypeIdentity,
                            productImport.RequiredMetadata,
                            productImport.Cardinality,
                            productImport.IsRecomposable,
                            false,
                            CreationPolicy.NonShared,
                            metadata));
                }
                else
                {
                    import = new ReflectionMemberImportDefinition(
                        importingMember,
                        contractName,
                        requiredTypeIdentity,
                        productImport.RequiredMetadata,
                        productImport.Cardinality,
                        productImport.IsRecomposable,
                        false,
                        productImport.RequiredCreationPolicy,
                        metadata,
                        ((ICompositionElement)memberImport).Origin);
                }

                members.Add(lazyMember);
            }
            else
            {
                ReflectionParameterImportDefinition?parameterImport = reflectionImport as ReflectionParameterImportDefinition;
                if (parameterImport == null)
                {
                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
                }

                Lazy <ParameterInfo> lazyParameter = parameterImport.ImportingLazyParameter;
                Lazy <ParameterInfo> parameter     = new Lazy <ParameterInfo>(() => GetParameter(lazyParameter));

                if (isExportFactory)
                {
                    import = new PartCreatorParameterImportDefinition(
                        parameter,
                        ((ICompositionElement)parameterImport).Origin,
                        new ContractBasedImportDefinition(
                            contractName,
                            requiredTypeIdentity,
                            productImport.RequiredMetadata,
                            productImport.Cardinality,
                            false,
                            true,
                            CreationPolicy.NonShared,
                            metadata));
                }
                else
                {
                    import = new ReflectionParameterImportDefinition(
                        parameter,
                        contractName,
                        requiredTypeIdentity,
                        productImport.RequiredMetadata,
                        productImport.Cardinality,
                        productImport.RequiredCreationPolicy,
                        metadata,
                        ((ICompositionElement)parameterImport).Origin);
                }

                parameters.Add(lazyParameter);
            }

            return(import);
        }
        private ImportDefinition TranslateImport(ReflectionImportDefinition reflectionImport, List<LazyMemberInfo> members, List<Lazy<ParameterInfo>> parameters)
        {
            bool isExportFactory = false;
            ContractBasedImportDefinition productImport = reflectionImport;

            IPartCreatorImportDefinition exportFactoryImportDefinition = reflectionImport as IPartCreatorImportDefinition;
            if (exportFactoryImportDefinition != null)
            {
                productImport = exportFactoryImportDefinition.ProductImportDefinition;
                isExportFactory = true;
            }

            string contractName = this.Translate(productImport.ContractName);
            string requiredTypeIdentity = this.Translate(productImport.RequiredTypeIdentity);
            IDictionary<string, object> metadata = this.TranslateImportMetadata(productImport);
            
            ReflectionMemberImportDefinition memberImport = reflectionImport as ReflectionMemberImportDefinition;
            ImportDefinition import = null;
            if (memberImport != null)
            {
                LazyMemberInfo lazyMember = memberImport.ImportingLazyMember;
                LazyMemberInfo importingMember = new LazyMemberInfo(lazyMember.MemberType, () => GetAccessors(lazyMember));

                if (isExportFactory)
                {
                    import = new PartCreatorMemberImportDefinition(
                        importingMember,
                        ((ICompositionElement)memberImport).Origin,
                        new ContractBasedImportDefinition(
                            contractName,
                            requiredTypeIdentity,
                            productImport.RequiredMetadata,
                            productImport.Cardinality,
                            productImport.IsRecomposable,
                            false,
                            CreationPolicy.NonShared,
                            metadata));
                }
                else
                {
                    import = new ReflectionMemberImportDefinition(
                         importingMember,
                         contractName,
                         requiredTypeIdentity,
                         productImport.RequiredMetadata,
                         productImport.Cardinality,
                         productImport.IsRecomposable,
                         false,
                         productImport.RequiredCreationPolicy,
                         metadata,
                         ((ICompositionElement)memberImport).Origin);
                }

                members.Add(lazyMember);
            }
            else
            {
                ReflectionParameterImportDefinition parameterImport = reflectionImport as ReflectionParameterImportDefinition;
                Assumes.NotNull(parameterImport);

                Lazy<ParameterInfo> lazyParameter = parameterImport.ImportingLazyParameter;
                Lazy<ParameterInfo> parameter = new Lazy<ParameterInfo>(() => GetParameter(lazyParameter));

                if (isExportFactory)
                {
                    import = new PartCreatorParameterImportDefinition(
                            parameter,
                            ((ICompositionElement)parameterImport).Origin,
                            new ContractBasedImportDefinition(
                                contractName,
                                requiredTypeIdentity,
                                productImport.RequiredMetadata,
                                productImport.Cardinality,
                                false,
                                true,
                                CreationPolicy.NonShared,
                                metadata));
                }
                else
                {
                    import = new ReflectionParameterImportDefinition(
                         parameter,
                         contractName,
                         requiredTypeIdentity,
                         productImport.RequiredMetadata,
                         productImport.Cardinality,
                         productImport.RequiredCreationPolicy,
                         metadata,
                         ((ICompositionElement)parameterImport).Origin);
                }

                parameters.Add(lazyParameter);
            }

            return import;
        }