/// <summary> /// Find line in Hashable and udpate Result /// </summary> /// <param name="hashtable">Reference to collection</param> /// <param name="result">Reserence to Result</param> /// <param name="thisTuner">Tnis object Tuner</param> private void ReadFromHashtable(Hashtable hashtable, Result result, ref Tuner thisTuner) { // If checker become intune if (this.inTune == 1) { // We do not need of tuner more thisTuner = null; } // Get result from hashtable if (hashtable.Contains(result.SearchLine)) { result.Increace((int)hashtable[result.SearchLine]); } }
/// <summary> /// Trying find line in Hashable and udpate Result /// </summary> /// <param name="result">Reserence to Result</param> /// <param name="thisTuner">Tnis object Tuner</param> /// <param name="hashtable">Reference to collection</param> private Boolean TryReadFromHashtable(Result result, ref Tuner thisTuner, out Hashtable hashtable) { Boolean success = false; hashtable = hashtableWeakReference.Target as Hashtable; if (hashtable != null) { // Hashtable is exist ReadFromHashtable(hashtable, result, ref thisTuner); success = true; } return(success); }
/// <summary> /// Parse the part of file and update Result object and hashtable /// </summary> /// <param name="result">Result reference</param> /// <param name="thisTuner">Reference to this Tuner</param> /// <param name="prevTuner">Reference to previous Tuner</param> /// <param name="token">Cancellation Token</param> /// <returns>Referеnce to hashtable</returns> private Hashtable Parse(Result result, Tuner thisTuner, Tuner prevTuner, CancellationToken token) { Hashtable hashtable = new Hashtable(); using (Stream stream = this.GetStream()) { using (StreamReader streamReader = new StreamReader(stream)) { // Process first line string line = streamReader.ReadLine(); if (this.firstCall && prevTuner != null) { // Take the first line during the first pass this.firstSubline = line; this.innerOffset = String.IsNullOrEmpty(line) ? 0 : line.Length; } else { DoLineCheck(line, result, hashtable); } this.firstCall = false; // Now execution can be canceled // Process body Boolean done = streamReader.EndOfStream; while (!done) { line = streamReader.ReadLine(); if (!streamReader.EndOfStream) { // Process all string but not last one DoLineCheck(line, result, hashtable); } else { done = true; } if (token.IsCancellationRequested) { // Do not save broken hashtable hashtable = null; done = true; } } if (!token.IsCancellationRequested) { // Process last line if (this.inTune == 0) { //Save last string this.lastSubline = line; } // If tuner stil alive he should process this line, // even if checker already in tune if (thisTuner == null) { // Tune is done - process last line // Hastable was collect, but offset and byte count already changed DoLineCheck(line, result, hashtable); } } } } return(hashtable); }