示例#1
0
文件: CRC32.cs 项目: Simakeng/Sync
 public void Compute <T>(T value)
 {
     foreach (var GetBytes in typeof(BitConverter).GetMethods())
     {
         if (GetBytes.Name != "GetBytes")
         {
             continue;
         }
         if (GetBytes.GetParameters()[0].ParameterType != typeof(T))
         {
             continue;
         }
         var bytes = GetBytes.Invoke(null, new object[] { value }) as byte[];
         Compute(bytes);
         return;
     }
     throw new Exception("BitConverter Don't have GetBytes Instance that recive parameter with type " + typeof(T).FullName);
 }