public IgnoreErrorSectionsHandler(string file, Options options = null) { if (options == null) { options = OptionsProviderRegistry.CurrentOptions; } SectionsToIgnore = new List <IgnoreErrorSection>(); string start = options.IgnoreErrorStart, end = options.IgnoreErrorEnd, ignoreline = options.IgnoreErrorLine; int line = 1, startLineCharacter = 0, endLineCharacter = 0, character = 0, i; IgnoreErrorSection currentSection = null; bool lookAtStartEnd = true, lookAtLines = true; if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) { lookAtStartEnd = false; } if (string.IsNullOrEmpty(ignoreline)) { lookAtLines = false; } while (lookAtLines || lookAtStartEnd) { endLineCharacter = file.IndexOf('\n', startLineCharacter); character = startLineCharacter; if (endLineCharacter < 0) { break; } while (true) { if (currentSection != null) { i = file.IndexOf(end, character, endLineCharacter - character); if (i >= 0) { currentSection.EndLine = line; currentSection.EndCol = i - startLineCharacter; SectionsToIgnore.Add(currentSection); currentSection = null; character = i; continue; } break; } i = file.IndexOf(ignoreline, character, endLineCharacter - character); if (i >= 0) { SectionsToIgnore.Add(new IgnoreErrorSection() { StartLine = line, EndLine = line, StartCol = -1 }); break; } i = file.IndexOf(start, character, endLineCharacter - character); if (i >= 0) { currentSection = new IgnoreErrorSection() { StartLine = line, StartCol = i - startLineCharacter }; character = i; } else { break; } } line++; startLineCharacter = endLineCharacter + 1; } }
public IgnoreErrorSectionsHandler(string file, Options options = null) { if (options == null) { options = OptionsProviderRegistry.CurrentOptions; } SectionsToIgnore = new List<IgnoreErrorSection>(); string start = options.IgnoreErrorStart, end = options.IgnoreErrorEnd, ignoreline = options.IgnoreErrorLine; int line = 1, startLineCharacter = 0, endLineCharacter = 0, character = 0, i; IgnoreErrorSection currentSection = null; bool lookAtStartEnd = true, lookAtLines = true; if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) { lookAtStartEnd = false; } if (string.IsNullOrEmpty(ignoreline)) { lookAtLines = false; } while (lookAtLines || lookAtStartEnd) { endLineCharacter = file.IndexOf('\n', startLineCharacter); character = startLineCharacter; if (endLineCharacter < 0) { break; } while (true) { if (currentSection != null) { i = file.IndexOf(end, character, endLineCharacter - character); if (i >= 0) { currentSection.EndLine = line; currentSection.EndCol = i - startLineCharacter; SectionsToIgnore.Add(currentSection); currentSection = null; character = i; continue; } break; } i = file.IndexOf(ignoreline, character, endLineCharacter - character); if (i >= 0) { SectionsToIgnore.Add(new IgnoreErrorSection() { StartLine = line, EndLine = line, StartCol = -1 }); break; } i = file.IndexOf(start, character, endLineCharacter - character); if (i >= 0) { currentSection = new IgnoreErrorSection() { StartLine = line, StartCol = i - startLineCharacter }; character = i; } else { break; } } line++; startLineCharacter = endLineCharacter + 1; } }