Beispiel #1
0
 public void ConvertObjectToByteArray <T>(T obj)
 {
     if (obj is ICollection)
     {
         var collection = obj as ICollection;
         var dataAll    = new byte[0];
         foreach (var coll in collection)
         {
             //获取当前实体类转换成的字节数组
             var data = CommonConvert.GetObjData(coll);
             //创建新的数组进行合并并赋值给变量保存
             var bytes = new byte[data.Length + dataAll.Length];
             dataAll.CopyTo(bytes, 0);
             data.CopyTo(bytes, dataAll.Length);
             dataAll = bytes;
         }
         DataSize     = dataAll.Length;
         _dataPackage = dataAll;
     }
 }