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); }
public override void PreBuildUp(IBuilderContext context) { var policy = BuildTracking.GetPolicy(context) ?? BuildTracking.SetPolicy(context); policy.BuildKeys.Push(context.BuildKey); }
public override void PostBuildUp(IBuilderContext context) { IBuildTrackingPolicy policy = BuildTracking.GetPolicy(context); if ((policy != null) && (policy.BuildKeys.Count > 0)) { policy.BuildKeys.Pop(); } }