private void BuildUp(BuildObject build, ErrorTracer errorTracer, BuildParameter[] buildParameters)
 {
     lock (build.Export)
     {
         var context = new DefaultBuildContext(build, container, errorTracer, buildParameters);
         build.Instance = context.Target;
         Pipeline.Build(context);
     }
 }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="toBuild"></param>
        /// <param name="export">
        ///     The export.
        /// </param>
        /// <param name="errorTracer"></param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        public object BuildUp(object toBuild, ErrorTracer errorTracer, BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");
            Contract.Requires<ArgumentNullException>(toBuild != null, "export");

            lock (toBuild)
            {
                try
                {
                    errorTracer.Phase = "Begin Building Up";
                    var context = new DefaultBuildContext(
                        _factory.CreateAnonymosWithTarget(toBuild.GetType(), toBuild),
                        BuildMode.BuildUpObject,
                        container,
                        toBuild.GetType().Name, errorTracer,
                        buildParameters, _componentRegistry.GetAll<IResolverExtension>().ToArray());
                    Pipeline.Build(context);
                    Contract.Assume(context.Target != null);
                    return context.Target;
                }
                catch (Exception e)
                {
                    errorTracer.Exceptional = true;
                    errorTracer.Exception = e;
                    return null;
                }
            }
        }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="type">
        ///     The type.
        /// </param>
        /// <param name="constructorArguments">
        ///     The constructor arguments.
        /// </param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        internal object BuildUp(Type type, object[] constructorArguments, ErrorTracer errorTracer, BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(type != null, "type");

            errorTracer.Phase = "Begin Building Up";
            try
            {
                var context = new DefaultBuildContext(
                    _factory.CreateAnonymos(type, constructorArguments),
                    BuildMode.BuildUpObject,
                    container,
                    type.Name, errorTracer,
                    buildParameters, _componentRegistry.GetAll<IResolverExtension>().ToArray());
                Pipeline.Build(context);
                Contract.Assume(context.Target != null);
                return context.Target;
            }
            catch (Exception e)
            {
                errorTracer.Exceptional = true;
                errorTracer.Exception = e;
                return null;
            }
        }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="export">
        ///     The export.
        /// </param>
        /// <param name="contractName">
        ///     The contract name.
        /// </param>
        /// <param name="tracer"></param>
        /// <param name="buildParameters"></param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        public object BuildUp(IExport export, string contractName, ErrorTracer tracer, BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(export != null, "export");

            lock (export)
            {
                try
                {
                    tracer.Phase = "Begin Building Up";
                    var context = new DefaultBuildContext(export, BuildMode.Resolve, container, contractName,
                        tracer, buildParameters, _componentRegistry.GetAll<IResolverExtension>().ToArray());
                    var buildObject = new BuildObject(export.ImportMetadata, context.Metadata, buildParameters);
                    Pipeline.Build(context);
                    if (tracer.Exceptional) return null;
                    buildObject.Instance = context.Target;
                    if (!export.ExternalInfo.External && !export.ExternalInfo.HandlesLiftime)
                        RebuildManager.AddBuild(buildObject);

                    Contract.Assume(context.Target != null);
                    return context.Target;
                }
                catch (Exception e)
                {
                    tracer.Exceptional = true;
                    tracer.Exception = e;
                    return null;
                }
            }
        }