Exemple #1
0
 public static TdrError.ErrorType printVariable(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, bool withSep)
 {
     TdrError.ErrorType errorType = TdrBufUtil.printMultiStr(ref buf, "    ", indent);
     if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
     {
         if (withSep)
         {
             errorType = buf.sprintf("{0}[{1:d}]{2}", new object[]
             {
                 variable,
                 arrIdx,
                 sep
             });
         }
         else
         {
             errorType = buf.sprintf("{0}[{1:d}]: ", new object[]
             {
                 variable,
                 arrIdx
             });
         }
     }
     return(errorType);
 }
Exemple #2
0
        public static TdrError.ErrorType tdrIP2Str(ref TdrVisualBuf buf, uint ip)
        {
            string str = new IPAddress((long)ip).ToString();

            object[] args = new object[] { str };
            return(buf.sprintf("{0}", args));
        }
Exemple #3
0
 public static TdrError.ErrorType printWString(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, short[] str)
 {
     TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
     object[]           args = new object[] { variable, arrIdx };
     type = buf.sprintf("{0}[{1:d}]", args);
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         int num = TdrTypeUtil.wstrlen(str);
         for (int i = 0; i < num; i++)
         {
             object[] objArray2 = new object[] { str[i] };
             type = buf.sprintf("0x{0:X4}", objArray2);
             if (type != TdrError.ErrorType.TDR_NO_ERROR)
             {
                 break;
             }
         }
     }
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         object[] objArray3 = new object[] { sep };
         type = buf.sprintf("{0}", objArray3);
     }
     return(type);
 }
Exemple #4
0
 public static TdrError.ErrorType printWString(ref TdrVisualBuf buf, int indent, char sep, string variable, short[] str)
 {
     TdrError.ErrorType errorType = buf.sprintf("{0}:  ", new object[]
     {
         variable
     });
     if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
     {
         int num = TdrTypeUtil.wstrlen(str);
         for (int i = 0; i < num; i++)
         {
             errorType = buf.sprintf("0x{0:X4}", new object[]
             {
                 str[i]
             });
             if (errorType != TdrError.ErrorType.TDR_NO_ERROR)
             {
                 break;
             }
         }
     }
     if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
     {
         errorType = buf.sprintf("{0}", new object[]
         {
             sep
         });
     }
     return(errorType);
 }
Exemple #5
0
        public static TdrError.ErrorType printString(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, byte[] bStr)
        {
            TdrError.ErrorType errorType = TdrError.ErrorType.TDR_NO_ERROR;
            string             text      = string.Empty;
            int num = TdrTypeUtil.cstrlen(bStr);

            if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
            {
                errorType = TdrBufUtil.printMultiStr(ref buf, "    ", indent);
            }
            if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
            {
                text = Encoding.get_ASCII().GetString(bStr, 0, num);
            }
            if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
            {
                errorType = buf.sprintf("{0}[{1:d}]: {2}{3}", new object[]
                {
                    variable,
                    arrIdx,
                    text,
                    sep
                });
            }
            return(errorType);
        }
Exemple #6
0
        public static TdrError.ErrorType tdrDateTime2Str(ref TdrVisualBuf buf, UInt64 datetime)
        {
            TdrError.ErrorType ret         = TdrError.ErrorType.TDR_NO_ERROR;
            TdrDateTime        tdrDateTime = new TdrDateTime();

            ret = tdrDateTime.parse(datetime);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0:d4}-{1:d2}-{2:d2} {3:d2}:{4:d2}:{5:d2}",
                                  tdrDateTime.tdrDate.nYear, tdrDateTime.tdrDate.bMon, tdrDateTime.tdrDate.bDay,
                                  tdrDateTime.tdrTime.nHour, tdrDateTime.tdrTime.bMin, tdrDateTime.tdrTime.bSec);
            }
            else
            {
#if (DEBUG)
                StackTrace st = new StackTrace(true);
                for (int i = 0; i < st.FrameCount; i++)
                {
                    if (null != st.GetFrame(i).GetFileName())
                    {
                        Console.WriteLine(st.GetFrame(i).ToString());
                    }
                }
#endif
                ret = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE;
            }

            return(ret);
        }
Exemple #7
0
        public static TdrError.ErrorType printWString(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, Int16[] str)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;
            int count = TdrTypeUtil.wstrlen(str) + 1;

            ret = buf.sprintf("{0}[{1:d}]", variable, arrIdx);
            if (ret == TdrError.ErrorType.TDR_NO_ERROR)
            {
                int len = TdrTypeUtil.wstrlen(str);
                for (int i = 0; i < len; i++)
                {
                    ret = buf.sprintf("0x{0:X4}", str[i]);
                    if (TdrError.ErrorType.TDR_NO_ERROR != ret)
                    {
                        break;
                    }
                }
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}", sep);
            }

            return(ret);
        }
Exemple #8
0
        public static TdrError.ErrorType tdrIP2Str(ref TdrVisualBuf buf, uint ip)
        {
            IPAddress iPAddress = new IPAddress((long)((ulong)ip));
            string    text      = iPAddress.ToString();

            return(buf.sprintf("{0}", new object[]
            {
                text
            }));
        }
Exemple #9
0
        public static TdrError.ErrorType tdrIP2Str(ref TdrVisualBuf buf, UInt32 ip)
        {
            TdrError.ErrorType ret     = TdrError.ErrorType.TDR_NO_ERROR;
            IPAddress          address = new IPAddress((Int64)ip);
            string             strip   = address.ToString();

            ret = buf.sprintf("{0}", strip);

            return(ret);
        }
Exemple #10
0
        public static TdrError.ErrorType tdrDate2Str(ref TdrVisualBuf buf, uint date)
        {
            TdrDate date2 = new TdrDate();

            if (date2.parse(date) == TdrError.ErrorType.TDR_NO_ERROR)
            {
                object[] args = new object[] { date2.nYear, date2.bMon, date2.bDay };
                return(buf.sprintf("{0:d4}-{1:d2}-{2:d2}", args));
            }
            return(TdrError.ErrorType.TDR_ERR_INVALID_TDRDATE_VALUE);
        }
Exemple #11
0
        public static TdrError.ErrorType tdrTime2Str(ref TdrVisualBuf buf, uint time)
        {
            TdrTime time2 = new TdrTime();

            if (time2.parse(time) == TdrError.ErrorType.TDR_NO_ERROR)
            {
                object[] args = new object[] { time2.nHour, time2.bMin, time2.bSec };
                return(buf.sprintf("{0:d2}:{1:d2}:{2:d2}", args));
            }
            return(TdrError.ErrorType.TDR_ERR_INVALID_TDRTIME_VALUE);
        }
Exemple #12
0
        public static TdrError.ErrorType tdrDateTime2Str(ref TdrVisualBuf buf, ulong datetime)
        {
            TdrDateTime time = new TdrDateTime();

            if (time.parse(datetime) == TdrError.ErrorType.TDR_NO_ERROR)
            {
                object[] args = new object[] { time.tdrDate.nYear, time.tdrDate.bMon, time.tdrDate.bDay, time.tdrTime.nHour, time.tdrTime.bMin, time.tdrTime.bSec };
                return(buf.sprintf("{0:d4}-{1:d2}-{2:d2} {3:d2}:{4:d2}:{5:d2}", args));
            }
            return(TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE);
        }
Exemple #13
0
 public static TdrError.ErrorType printArray(ref TdrVisualBuf buf, int indent, char sep, string variable, long count)
 {
     TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
     type = printMultiStr(ref buf, "    ", indent);
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         object[] args = new object[] { variable, count };
         type = buf.sprintf("{0}[0:{1:d}]: ", args);
     }
     return(type);
 }
Exemple #14
0
        public static TdrError.ErrorType printArray(ref TdrVisualBuf buf, int indent, char sep, string variable, Int64 count)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;

            ret = printMultiStr(ref buf, "    ", indent);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}[0:{1:d}]: ", variable, count);
            }

            return(ret);
        }
Exemple #15
0
 public static TdrError.ErrorType printArray(ref TdrVisualBuf buf, int indent, char sep, string variable, long count)
 {
     TdrError.ErrorType errorType = TdrBufUtil.printMultiStr(ref buf, "    ", indent);
     if (errorType == TdrError.ErrorType.TDR_NO_ERROR)
     {
         errorType = buf.sprintf("{0}[0:{1:d}]: ", new object[]
         {
             variable,
             count
         });
     }
     return(errorType);
 }
Exemple #16
0
        public static TdrError.ErrorType printMultiStr(ref TdrVisualBuf buf, string str, int times)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;

            for (int i = 0; i < times; i++)
            {
                ret = buf.sprintf("{0}", str);
                if (ret != TdrError.ErrorType.TDR_NO_ERROR)
                {
                    break;
                }
            }
            return(ret);
        }
Exemple #17
0
 public static TdrError.ErrorType printMultiStr(ref TdrVisualBuf buf, string str, int times)
 {
     TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
     for (int i = 0; i < times; i++)
     {
         object[] args = new object[] { str };
         type = buf.sprintf("{0}", args);
         if (type != TdrError.ErrorType.TDR_NO_ERROR)
         {
             return(type);
         }
     }
     return(type);
 }
Exemple #18
0
 public static TdrError.ErrorType printVariable(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, bool withSep)
 {
     TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
     type = printMultiStr(ref buf, "    ", indent);
     if (type != TdrError.ErrorType.TDR_NO_ERROR)
     {
         return(type);
     }
     if (withSep)
     {
         object[] objArray1 = new object[] { variable, arrIdx, sep };
         return(buf.sprintf("{0}[{1:d}]{2}", objArray1));
     }
     object[] args = new object[] { variable, arrIdx };
     return(buf.sprintf("{0}[{1:d}]: ", args));
 }
Exemple #19
0
 public static TdrError.ErrorType printMultiStr(ref TdrVisualBuf buf, string str, int times)
 {
     TdrError.ErrorType errorType = TdrError.ErrorType.TDR_NO_ERROR;
     for (int i = 0; i < times; i++)
     {
         errorType = buf.sprintf("{0}", new object[]
         {
             str
         });
         if (errorType != TdrError.ErrorType.TDR_NO_ERROR)
         {
             break;
         }
     }
     return(errorType);
 }
Exemple #20
0
        public static TdrError.ErrorType printVariable(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, bool withSep)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;

            ret = printMultiStr(ref buf, "    ", indent);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                if (withSep)
                {
                    ret = buf.sprintf("{0}[{1:d}]{2}", variable, arrIdx, sep);
                }
                else
                {
                    ret = buf.sprintf("{0}[{1:d}]: ", variable, arrIdx);
                }
            }

            return(ret);
        }
Exemple #21
0
 public static TdrError.ErrorType printTdrDate(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, uint date)
 {
     TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
     type = printMultiStr(ref buf, "    ", indent);
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         object[] args = new object[] { variable, arrIdx };
         type = buf.sprintf("{0}[{1:d}]: ", args);
     }
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         type = TdrTypeUtil.tdrDate2Str(ref buf, date);
     }
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         object[] objArray2 = new object[] { sep };
         type = buf.sprintf("{0}", objArray2);
     }
     return(type);
 }
Exemple #22
0
        public static TdrError.ErrorType tdrDate2Str(ref TdrVisualBuf buf, uint date)
        {
            TdrDate tdrDate = new TdrDate();

            TdrError.ErrorType result;
            if (tdrDate.parse(date) == TdrError.ErrorType.TDR_NO_ERROR)
            {
                result = buf.sprintf("{0:d4}-{1:d2}-{2:d2}", new object[]
                {
                    tdrDate.nYear,
                    tdrDate.bMon,
                    tdrDate.bDay
                });
            }
            else
            {
                result = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATE_VALUE;
            }
            return(result);
        }
Exemple #23
0
 public static TdrError.ErrorType printVariable(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, string format, params object[] args)
 {
     TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
     type = printMultiStr(ref buf, "    ", indent);
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         object[] objArray1 = new object[] { variable, arrIdx };
         type = buf.sprintf("{0}[{1:d}]: ", objArray1);
     }
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         type = buf.sprintf(format, args);
     }
     if (type == TdrError.ErrorType.TDR_NO_ERROR)
     {
         object[] objArray2 = new object[] { sep };
         type = buf.sprintf("{0}", objArray2);
     }
     return(type);
 }
Exemple #24
0
        public static TdrError.ErrorType tdrTime2Str(ref TdrVisualBuf buf, uint time)
        {
            TdrTime tdrTime = new TdrTime();

            TdrError.ErrorType result;
            if (tdrTime.parse(time) == TdrError.ErrorType.TDR_NO_ERROR)
            {
                result = buf.sprintf("{0:d2}:{1:d2}:{2:d2}", new object[]
                {
                    tdrTime.nHour,
                    tdrTime.bMin,
                    tdrTime.bSec
                });
            }
            else
            {
                result = TdrError.ErrorType.TDR_ERR_INVALID_TDRTIME_VALUE;
            }
            return(result);
        }
Exemple #25
0
        public static TdrError.ErrorType printString(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, byte[] bStr)
        {
            TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR;
            string             str  = string.Empty;
            int count = TdrTypeUtil.cstrlen(bStr);

            if (type == TdrError.ErrorType.TDR_NO_ERROR)
            {
                type = printMultiStr(ref buf, "    ", indent);
            }
            if (type == TdrError.ErrorType.TDR_NO_ERROR)
            {
                str = Encoding.ASCII.GetString(bStr, 0, count);
            }
            if (type == TdrError.ErrorType.TDR_NO_ERROR)
            {
                object[] args = new object[] { variable, arrIdx, str, sep };
                type = buf.sprintf("{0}[{1:d}]: {2}{3}", args);
            }
            return(type);
        }
Exemple #26
0
        public static TdrError.ErrorType printTdrDateTime(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, UInt64 datetime)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;

            ret = printMultiStr(ref buf, "    ", indent);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}[{1:d}]: ", variable, arrIdx);
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = TdrTypeUtil.tdrDateTime2Str(ref buf, datetime);
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}", sep);
            }

            return(ret);
        }
Exemple #27
0
        public static TdrError.ErrorType printVariable(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, string format, params object[] args)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;

            ret = printMultiStr(ref buf, "    ", indent);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}[{1:d}]: ", variable, arrIdx);
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf(format, args);
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}", sep);
            }

            return(ret);
        }
Exemple #28
0
        public static TdrError.ErrorType printTdrTime(ref TdrVisualBuf buf, int indent, char sep, string variable, UInt32 time)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;

            ret = printMultiStr(ref buf, "    ", indent);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}: ", variable);
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = TdrTypeUtil.tdrTime2Str(ref buf, time);
            }

            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0}", sep);
            }

            return(ret);
        }
Exemple #29
0
        public static TdrError.ErrorType printString(ref TdrVisualBuf buf, int indent, char sep, string variable, int arrIdx, byte[] bStr)
        {
            TdrError.ErrorType ret    = TdrError.ErrorType.TDR_NO_ERROR;
            string             strUni = "";
            int count = TdrTypeUtil.cstrlen(bStr);

            if (ret == TdrError.ErrorType.TDR_NO_ERROR)
            {
                ret = printMultiStr(ref buf, "    ", indent);
            }

            if (ret == TdrError.ErrorType.TDR_NO_ERROR)
            {
                strUni = Encoding.ASCII.GetString(bStr, 0, count);
            }

            if (ret == TdrError.ErrorType.TDR_NO_ERROR)
            {
                ret = buf.sprintf("{0}[{1:d}]: {2}{3}", variable, arrIdx, strUni, sep);
            }

            return(ret);
        }
Exemple #30
0
        public static TdrError.ErrorType tdrDateTime2Str(ref TdrVisualBuf buf, ulong datetime)
        {
            TdrDateTime tdrDateTime = new TdrDateTime();

            TdrError.ErrorType result;
            if (tdrDateTime.parse(datetime) == TdrError.ErrorType.TDR_NO_ERROR)
            {
                result = buf.sprintf("{0:d4}-{1:d2}-{2:d2} {3:d2}:{4:d2}:{5:d2}", new object[]
                {
                    tdrDateTime.tdrDate.nYear,
                    tdrDateTime.tdrDate.bMon,
                    tdrDateTime.tdrDate.bDay,
                    tdrDateTime.tdrTime.nHour,
                    tdrDateTime.tdrTime.bMin,
                    tdrDateTime.tdrTime.bSec
                });
            }
            else
            {
                result = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE;
            }
            return(result);
        }