Exemplo n.º 1
0
 public bool WriteString(Tracekind kind, string data)
 {
     if (this.UseTrace || this.isDebug)
     {
         try
         {
             StreamWriter writer = this.OpenTrace();
             if (writer == null)
             {
                 return false;
             }
             try
             {
                 if (kind == Tracekind.START)
                 {
                     writer.WriteLine("{0} [{1,-5}] : {2}", this.DateTimeString(), kind, "=====< Trace Start >=====");
                 }
                 else
                 {
                     writer.WriteLine("{0} [{1,-5}] : {2}", this.DateTimeString(), kind, data);
                 }
             }
             finally
             {
                 writer.Close();
             }
         }
         catch
         {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public bool WriteDump(Tracekind kind, string data, bool isSend)
 {
     if (this.UseTrace || this.isDebug)
     {
         try
         {
             StreamWriter writer = this.OpenTrace();
             if (writer == null)
             {
                 return false;
             }
             Encoding encoding = writer.Encoding;
             byte[] bytes = encoding.GetBytes(this.DumpData(data));
             try
             {
                 string str;
                 string str2;
                 if (isSend)
                 {
                     str = string.Format("<SEND DATA HEX DUMP({0})>", encoding.EncodingName);
                 }
                 else
                 {
                     str = string.Format("<RECEIVE DATA HEX DUMP({0})>", encoding.EncodingName);
                 }
                 writer.WriteLine("{0} [{1,-5}] : {2}", this.DateTimeString(), kind, str);
                 writer.WriteLine("< DUMP > 0------- 4------- 8------- C-------  0---4---8---C---");
                 int num = 0;
                 int num2 = 0;
                 byte[] buffer2 = new byte[0x10];
                 int count = 0;
                 long num4 = 0L;
                 long num5 = 0L;
             Label_009E:
                 str2 = string.Format("{0:X08} ", num5);
                 buffer2 = new byte[0x10];
                 count = 0;
                 int index = 0;
                 for (num = 0; num <= 3; num++)
                 {
                     for (num2 = 0; num2 <= 3; num2++)
                     {
                         if (num4 < bytes.Length)
                         {
                             str2 = str2 + string.Format("{0:X02}", bytes[(int) ((IntPtr) num4)]);
                             char c = (char) bytes[(int) ((IntPtr) num4)];
                             index = ((int) num4) % 0x10;
                             if (char.IsControl(c) && (c < '\x0014'))
                             {
                                 buffer2[index] = 0x2e;
                             }
                             else
                             {
                                 buffer2[index] = bytes[(int) ((IntPtr) num4)];
                             }
                             count++;
                         }
                         else
                         {
                             str2 = str2 + "  ";
                         }
                         num4 += 1L;
                     }
                     if (num4 >= bytes.Length)
                     {
                         break;
                     }
                     str2 = str2 + " ";
                 }
                 if (num4 < bytes.Length)
                 {
                     writer.WriteLine("{0} {1}", str2, encoding.GetString(buffer2, 0, count));
                     num5 += 1L;
                     goto Label_009E;
                 }
                 int num7 = 0x2d - str2.Length;
                 for (num4 = 0L; num4 < num7; num4 += 1L)
                 {
                     str2 = str2 + " ";
                 }
                 writer.WriteLine("{0} {1}", str2, encoding.GetString(buffer2, 0, count));
             }
             finally
             {
                 writer.WriteLine("");
                 writer.Close();
             }
         }
         catch
         {
             return false;
         }
     }
     return true;
 }