Example #1
0
 public override void PreBuildUp(IBuilderContext context)
 {
     base.PreBuildUp(context);
     if (context.Existing != null && context.Existing is IInstrumentationEventProvider)
     {
         IConfigurationSource         configurationSource = GetConfigurationSource(context);
         ConfigurationReflectionCache reflectionCache     = GetReflectionCache(context);
         NamedTypeBuildKey            key = (NamedTypeBuildKey)context.BuildKey;
         string id = key.Name;
         InstrumentationAttachmentStrategy instrumentation = new InstrumentationAttachmentStrategy();
         if (ConfigurationNameProvider.IsMadeUpName(id))
         {
             instrumentation.AttachInstrumentation(context.Existing, configurationSource, reflectionCache);
         }
         else
         {
             instrumentation.AttachInstrumentation(id, context.Existing, configurationSource, reflectionCache);
         }
     }
 }
        /// <summary>
        /// Implementation of <see cref="IBuilderStrategy.BuildUp"/>.
        /// </summary>
        /// <remarks>
        /// This implementation will attach instrumentation to the created objects.
        /// </remarks>
        /// <param name="context">The build context.</param>
        /// <param name="t">The type of the object being built.</param>
        /// <param name="existing">The existing instance of the object.</param>
        /// <param name="id">The ID of the object being built.</param>
        /// <returns>The built object.</returns>
        public override object BuildUp(IBuilderContext context, Type t, object existing, string id)
        {
            if (existing != null)
            {
                IConfigurationSource              configurationSource = GetConfigurationSource(context);
                ConfigurationReflectionCache      reflectionCache     = GetReflectionCache(context);
                InstrumentationAttachmentStrategy instrumentation     = new InstrumentationAttachmentStrategy();

                if (ConfigurationNameProvider.IsMadeUpName(id))
                {
                    instrumentation.AttachInstrumentation(existing, configurationSource, reflectionCache);
                }
                else
                {
                    instrumentation.AttachInstrumentation(id, existing, configurationSource, reflectionCache);
                }
            }

            return(base.BuildUp(context, t, existing, id));
        }