public override void PreBuildUp(IBuilderContext context)
    {
        var policy = BuildTrackingExtension.GetPolicy(context)
                     ?? BuildTrackingExtension.SetPolicy(context);

        policy.BuildKeys.Push(context.BuildKey);
    }
Exemplo n.º 2
0
    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.FullName.StartsWith("Microsoft.Practices"))
                {
                    break;
                }
            }
        }
        return(logType);
    }
    public override void PostBuildUp(IBuilderContext context)
    {
        IBuildTrackingPolicy policy = BuildTrackingExtension.GetPolicy(context);

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