public static T BytesToStruct(byte[] bytes, Encoding encoding)
 {
     if (bytes == null)
     {
         throw new ArgumentNullException("bytes");
     }
     if (bytes.Length != tSize)
     {
         throw new ArgumentException(string.Format("[{2}]数据长度与预期不一致,可能是数据结构不匹配,预期长度{0},实际长度{1}", tSize, bytes.Length, typeof(T)));
     }
     return((T)bytesToStructExecutor.Execute(null, new object[] { bytes, encoding }));
 }
 public static byte[] StructToBytes(T obj, Encoding encoding)
 {
     return(structToBytesExecutor.Execute(null, new object[] { obj, encoding }) as byte[]);
 }
Exemple #3
0
 public static string ObjectToString(T obj)
 {
     return(structToStringExecutor.Execute(null, new object[] { obj }) as string);
 }