/// <summary>
        /// Traces debugging information, if there is an appropriate policy.
        /// </summary>
        /// <param name="context">The build context.</param>
        /// <param name="typeToBuild">The type being built.</param>
        /// <param name="idToBuild">The ID being built.</param>
        /// <param name="format">The format of the message.</param>
        /// <param name="args">The message arguments.</param>
        protected void TraceBuildUp(IBuilderContext context, Type typeToBuild, string idToBuild, string format, params object[] args)
        {
            IBuilderTracePolicy policy = context.Policies.Get <IBuilderTracePolicy>(null, null);

            if (policy != null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, format, args);
                policy.Trace(Properties.Resources.BuilderStrategyTraceBuildUp, GetType().Name, typeToBuild.Name, idToBuild ?? "(null)", message);
            }
        }
        /// <summary>
        /// Traces debugging information, if there is an appropriate policy.
        /// </summary>
        /// <param name="context">The build context.</param>
        /// <param name="item">Item being torn down.</param>
        /// <param name="format">The format of the message.</param>
        /// <param name="args">The message arguments.</param>
        protected void TraceTearDown(IBuilderContext context, object item, string format, params object[] args)
        {
            IBuilderTracePolicy policy = context.Policies.Get <IBuilderTracePolicy>(null, null);

            if (policy != null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, format, args);
                policy.Trace(Properties.Resources.BuilderStrategyTraceTearDown, GetType().Name, item.GetType().Name, message);
            }
        }
示例#3
0
        private object DoBuildUp(IReadWriteLocator locator, Type typeToBuild, string idToBuild, object existing,
                                 PolicyList[] transientPolicies)
        {
            IBuilderStrategyChain chain = strategies.MakeStrategyChain();

            ThrowIfNoStrategiesInChain(chain);

            IBuilderContext     context = MakeContext(chain, locator, transientPolicies);
            IBuilderTracePolicy trace   = context.Policies.Get <IBuilderTracePolicy>(null, null);

            if (trace != null)
            {
                trace.Trace(Properties.Resources.BuildUpStarting, typeToBuild, idToBuild ?? "(null)");
            }

            object result = chain.Head.BuildUp(context, typeToBuild, existing, idToBuild);

            if (trace != null)
            {
                trace.Trace(Properties.Resources.BuildUpFinished, typeToBuild, idToBuild ?? "(null)");
            }

            return(result);
        }
示例#4
0
        private TItem DoTearDown <TItem>(IReadWriteLocator locator, TItem item)
        {
            IBuilderStrategyChain chain = strategies.MakeReverseStrategyChain();

            ThrowIfNoStrategiesInChain(chain);

            Type                type    = item.GetType();
            IBuilderContext     context = MakeContext(chain, locator);
            IBuilderTracePolicy trace   = context.Policies.Get <IBuilderTracePolicy>(null, null);

            if (trace != null)
            {
                trace.Trace(Properties.Resources.TearDownStarting, type);
            }

            TItem result = (TItem)chain.Head.TearDown(context, item);

            if (trace != null)
            {
                trace.Trace(Properties.Resources.TearDownFinished, type);
            }

            return(result);
        }