public TdrError.ErrorType visualize(ref TdrVisualBuf destBuf, int indent, char separator) { TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; object[] args = new object[] { this.dwDataLen }; type = TdrBufUtil.printVariable(ref destBuf, indent, separator, "[dwDataLen]", "{0:d}", args); if (type == TdrError.ErrorType.TDR_NO_ERROR) { if (0x100000 < this.dwDataLen) { return(TdrError.ErrorType.TDR_ERR_REFER_SURPASS_COUNT); } type = TdrBufUtil.printArray(ref destBuf, indent, separator, "[szData]", (long)this.dwDataLen); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } for (int i = 0; i < this.dwDataLen; i++) { object[] objArray2 = new object[] { this.szData[i] }; type = destBuf.sprintf("0x{0:x2}", objArray2); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } object[] objArray3 = new object[] { separator }; type = destBuf.sprintf("{0}", objArray3); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); }
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); }
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); }
public TdrError.ErrorType visualize(ref TdrVisualBuf destBuf, int indent, char separator) { TdrError.ErrorType errorType = TdrBufUtil.printVariable(ref destBuf, indent, separator, "[dwDataLen]", "{0:d}", new object[] { this.dwDataLen }); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } if (1048576u < this.dwDataLen) { return(TdrError.ErrorType.TDR_ERR_REFER_SURPASS_COUNT); } errorType = TdrBufUtil.printArray(ref destBuf, indent, separator, "[szData]", (long)((ulong)this.dwDataLen)); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int num = 0; while ((long)num < (long)((ulong)this.dwDataLen)) { errorType = destBuf.sprintf("0x{0:x2}", new object[] { this.szData[num] }); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } num++; } errorType = destBuf.sprintf("{0}", new object[] { separator }); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } return(errorType); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }