コード例 #1
0
        private static Type GetLogType(IBuilderContext context)
        {
            Type logType = typeof(T);

            IBuildTrackingPolicy buildTrackingPolicy = BuildTracking.GetPolicy(context);

            if ((buildTrackingPolicy != null) && (buildTrackingPolicy.BuildKeys.Count >= 2))
            {
                logType = ((NamedTypeBuildKey)buildTrackingPolicy.BuildKeys.ElementAt(1)).Type;
            }
            else
            {
                StackTrace stackTrace = new StackTrace();
                //first -two- nine are in the log creation strategy, can skip over them
                for (int i = 3; i < stackTrace.FrameCount; i++)
                {
                    StackFrame frame = stackTrace.GetFrame(i);
                    logType = frame.GetMethod().DeclaringType;
                    //Console.WriteLine(logType.FullName);
                    if (!logType.FullName.StartsWith(typeof(IUnityContainer).Namespace) && !logType.FullName.StartsWith("System"))
                    {
                        break;
                    }
                }
            }

            return(logType);
        }
コード例 #2
0
        public override void PreBuildUp(IBuilderContext context)
        {
            var policy = BuildTracking.GetPolicy(context)
                         ?? BuildTracking.SetPolicy(context);

            policy.BuildKeys.Push(context.BuildKey);
        }
コード例 #3
0
        public override void PostBuildUp(IBuilderContext context)
        {
            IBuildTrackingPolicy policy = BuildTracking.GetPolicy(context);

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