private static Type GetLogType(IBuilderContext context)
        {
            Type logType = null;
            IBuildTrackingPolicy buildTrackingPolicy = BuildTrackingExtension.GetPolicy(context);

            if ((buildTrackingPolicy != null) && (buildTrackingPolicy.BuildKeys.Count >= 2))
            {
                logType = ((NamedTypeBuildKey)buildTrackingPolicy.BuildKeys.ElementAt(1)).Type;
            }
            else
            {
                StackTrace stackTrace = new StackTrace();
                //first two are in the log creation strategy, can skip over them
                for (int i = 2; i < stackTrace.FrameCount; i++)
                {
                    StackFrame frame = stackTrace.GetFrame(i);
                    logType = frame.GetMethod().DeclaringType;
                    if (logType != null && !logType.FullName.StartsWith("Microsoft.Practices", StringComparison.Ordinal))
                    {
                        break;
                    }
                }
            }
            return(logType);
        }
Esempio n. 2
0
        public override void PreBuildUp(IBuilderContext context)
        {
            var policy = BuildTrackingExtension.GetPolicy(context)
                         ?? BuildTrackingExtension.SetPolicy(context);

            policy.BuildKeys.Push(context.BuildKey);
        }
Esempio n. 3
0
        public override void PostBuildUp(IBuilderContext context)
        {
            IBuildTrackingPolicy policy = BuildTrackingExtension.GetPolicy(context);

            if ((policy != null) && (policy.BuildKeys.Count > 0))
            {
                policy.BuildKeys.Pop();
            }
        }