public override void OnExecuteFinish(InjectorContext context)
 {
     context.Resolver = CreateResolver(_resolvers, _listType);
     _resolvers = null;
     _listType = null;
     _enumeratorHelper = null;
 }
 public override StepId NextElement(InjectorContext context)
 {
     if (context.Resolver != null)
         _resolvers.Add(context.Resolver);
     _enumeratorHelper.MoveNext();
     return _enumeratorHelper.NextId;
 }
        public override StepId OnExecute(InjectorContext context)
        {
            var export = context.ReflectionContext.FindExport();
            ReflectionContext reflectionContext = context.ReflectionContext;

            if (export == null) return StepId.Invalid;

            Type currentType = reflectionContext.CurrentType;
            bool isExportFactory = currentType.IsGenericType &&
                                   currentType.GetGenericTypeDefinition() == typeof (InstanceResolver<,>);
            Type factoryType = null;

            if (isExportFactory)
            {
                factoryType = currentType.GenericTypeArguments[0];
                reflectionContext.MetadataType = currentType.GenericTypeArguments[1];
                reflectionContext.Metadata =
                    context.ReflectionContext.MetadataFactory.CreateMetadata(context.ReflectionContext.MetadataType,
                                                                             export.Metadata);
            }

            context.Resolver = new SimpleResolver(export, context.Container, isExportFactory, factoryType,
                                                  reflectionContext.Metadata,
                                                  reflectionContext.MetadataType,
                                                  reflectionContext.InterceptorCallback,
                                                  currentType == typeof (ExportDescriptor), reflectionContext.ResolverExtensions);

            return base.OnExecute(context);
        }
        public override StepId OnExecute(InjectorContext context)
        {
            _listType = context.ReflectionContext.CurrentType;
            context.ReflectionContext.CurrentType = GetCurrentType(context.ReflectionContext);

            var findAllExports = context.ReflectionContext.FindAllExports();
            if (findAllExports == null) return StepId.Invalid;

            _resolvers = new List<IResolver>();
            _enumeratorHelper = new ExportEnumeratorHelper(findAllExports.GetEnumerator(), context.ReflectionContext);
            return StepId.Loop;
        }
        public override StepId OnExecute(InjectorContext context)
        {
            if (context.BuildParameters != null)
            {
                foreach (var export in from buildParameter in context.BuildParameters
                                       where buildParameter != null
                                       select buildParameter.CreateExport()
                                       into export
                                       where export != null
                                       select export)
                {
                    context.ReflectionContext.BuildParametersRegistry.Register(export, int.MaxValue);
                }
            }

            if (context.ImportInterceptor != null)
                context.ReflectionContext.InterceptorCallback =
                    new ImportInterceptorHelper(context.ImportInterceptor, (MemberInfo) context.MemberInfo,
                                                context.Metadata, context.Target).Intercept;

            object val;
            if (context.Metadata.Metadata.TryGetValue(LevelSpecificImport.LevelMetadata, out val))
            {
                try
                {
                    context.ReflectionContext.Level = (int) val;
                }
                catch (InvalidCastException)
                {
                    context.ReflectionContext.Level = int.MaxValue;
                }
            }
            else context.ReflectionContext.Level = int.MaxValue;

            return base.OnExecute(context);
        }
 public override StepId OnExecute(InjectorContext context)
 {
     context.ReflectionContext.AdditionalInfo = context.ReflectionContext.MemberType.GetGenericTypeDefinition();
     return base.OnExecute(context);
 }