Exemplo n.º 1
0
 internal static byte[] GetBytesWrap <T>(this IPacketConverter <T> converter, T value)
 {
     try
     {
         var buf = converter.GetBytes(value);
         if (buf == null)
         {
             buf = s_empty_bytes;
         }
         var len = converter.Length;
         if (len > 0 && len != buf.Length)
         {
             throw PacketException.ConvertMismatch(len);
         }
         return(buf);
     }
     catch (Exception ex) when(PacketException.WrapFilter(ex))
     {
         throw PacketException.ConvertError(ex);
     }
 }