예제 #1
0
 public bool AddPlace(long bp, int po)
 {
     Patcher.Pattern.Place place = new Patcher.Pattern.Place()
     {
         bufferPos = bp,
         position  = po
     };
     this.rePl.Add(place);
     return(true);
 }
예제 #2
0
 private bool ReplaceAllPatterns(Patcher.Pattern pt)
 {
     checked
     {
         bool result;
         if (!pt.ValidPattern)
         {
             this.state.AddMessage(pt.CurState, 0);
             result = false;
         }
         else
         {
             int num = 0;
             List <Patcher.Pattern.Place> allPlaces = pt.AllPlaces;
             try
             {
                 List <Patcher.Pattern.Place> .Enumerator enumerator = allPlaces.GetEnumerator();
                 while (enumerator.MoveNext())
                 {
                     Patcher.Pattern.Place current = enumerator.Current;
                     int  num2  = 0;
                     bool flag  = false;
                     bool flag2 = false;
                     if (!this.fileW.SetPosition(current.bufferPos - 1L))
                     {
                         this.state.AddMessage(this.fileW.CurState);
                         result = false;
                         return(result);
                     }
                     while (this.fileW.ReadNext(true))
                     {
                         int arg_91_0     = 0;
                         int bufferLength = this.fileW.BufferLength;
                         for (int i = arg_91_0; i <= bufferLength; i++)
                         {
                             if (num2 == 0)
                             {
                                 i = current.position;
                             }
                             if (pt.replace[num2].Length == 1)
                             {
                                 this.fileW.buffer[i] = pt.replace[num2][0];
                                 flag = true;
                             }
                             num2++;
                             if (flag && (pt.replace.Count == num2 || i == this.fileW.BufferLength))
                             {
                                 this.fileW.FlushBuffer();
                                 flag2 = true;
                                 flag  = false;
                             }
                             if (pt.replace.Count == num2)
                             {
                                 if (flag2)
                                 {
                                     num++;
                                 }
                                 this.fileW.RunAway();
                                 break;
                             }
                         }
                         Application.DoEvents();
                     }
                     if (this.fileW.CurState != null)
                     {
                         this.state.AddMessage(this.fileW.CurState);
                         result = false;
                         return(result);
                     }
                 }
                 ((IDisposable)enumerator).Dispose();
             }
             finally
             {
                 //List<Patcher.Pattern.Place>.Enumerator enumerator;
             }
             result = true;
         }
         return(result);
     }
 }