/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ContextInfo"/> class. /// </summary> /// <param name="pattern">The punctuation pattern.</param> /// <param name="offset">The offset.</param> /// <param name="context">The context (a string with the line contents).</param> /// <param name="reference">The reference (line number).</param> /// ------------------------------------------------------------------------------------ internal ContextInfo(PuncPattern pattern, int offset, string context, string reference) { m_position = pattern.ContextPos; string chr = pattern.Pattern; // For punctuation patterns the position indicated by offset refers to the place where // the first punctuation character occurs. There can be a leading character indicating // that the pattern was found preceded by a space or at the start of a paragraph. if (pattern.Pattern.Length > 1) { if (m_position == ContextPosition.WordInitial || m_position == ContextPosition.Isolated) { Debug.Assert(context[offset] == chr[1]); // Adjust offset to account for leading space which is actually in the data offset--; } } Initialize(chr, offset, context, reference); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor to build a fully specified PuncPattern object (used in tests) /// </summary> /// ------------------------------------------------------------------------------------ public PuncPattern(string pattern, ContextPosition context, PuncPatternStatus status) { Pattern = pattern; ContextPos = context; Status = status; }