internal static ParserTraceExecutionContext TraceExecution(IParserCursorState cursor, string name = null)
        {
            Contract.Requires(cursor != null);
            Contract.Requires(name == null || name.Length > 0);

            return(new ParserTraceExecutionContext(name, cursor));
        }
        /// <summary>
        /// Constructs a new instance of the <see cref="ParserTraceExecutionContext" /> class.
        /// </summary>
        /// <param name="name">Name of the parser to be traced.</param>
        /// <param name="cursor">The parser's cursor.</param>
        public ParserTraceExecutionContext(string name, IParserCursorState cursor)
        {
            Contract.Requires(name == null || name.Length > 0);
            Contract.Requires(cursor != null);

            if (ParserTraceSources.Execution.Switch.ShouldTrace(TraceEventType.Verbose) ||
                ParserTraceSources.Execution.Switch.ShouldTrace(TraceEventType.Start))
            {
                this.id     = Interlocked.Increment(ref lastTracedExecutionId);
                this.name   = ParserTraceSources.FormatName(name);
                this.cursor = cursor;

                stopwatch = new Stopwatch();
            }
        }
Beispiel #3
0
    internal static ParserTraceExecutionContext TraceExecution(IParserCursorState cursor, string name = null)
    {
      Contract.Requires(cursor != null);
      Contract.Requires(name == null || name.Length > 0);

      return new ParserTraceExecutionContext(name, cursor);
    }