private int CountOccurrences() { int result = 0; while (!_provider.EndValidation()) { char currentReadingSign = _provider.Read(); if (currentReadingSign == _search[0]) { bool isCoincidence = true; for (int i = 1; i < _search.Length; i++) { if (_provider.EndValidation()) { isCoincidence = false; break; } char nextSymbol = _provider.Read(); if (nextSymbol != _search[i]) { _provider.Seek(-1, SeekOrigin.Current); isCoincidence = false; break; } } if (isCoincidence) { result++; } } } return(result); }