Example #1
0
 public static string ComputeElementMd5(ClangSharp.Cursor Cursor)
 {
     using (var md5 = MD5.Create())
     {
         if (Cursor != null)
         {
             string Name       = Cursor.Spelling;
             string typeHash   = "";
             string file       = "";
             string Argument   = "";
             string ResultType = "";
             file     = Cursor.Location.File.ToString();
             typeHash = ComputeMd5(Cursor.Type);
             for (uint i = 0; i < Cursor.NumArguments; i++)
             {
                 Argument += ComputeMd5(Cursor.GetArgument(i).Type);
             }
             ResultType = ComputeMd5(Cursor.ResultType);
             byte[] CursorData = Encoding.ASCII.GetBytes(Name + typeHash + Argument + ResultType);
             var    hash       = md5.ComputeHash(CursorData);
             return(BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant());
         }
         else
         {
             return("");
         }
     }
 }
Example #2
0
 public static string ComputeMd5(ClangSharp.Cursor Cursor)
 {
     using (var md5 = MD5.Create())
     {
         if (Cursor != null)
         {
             string Name = Cursor.Spelling;
             if (string.IsNullOrEmpty(Name) == true)
             {
                 Name = "";
             }
             string typeHash   = "";
             string file       = "";
             string Argument   = "";
             string ResultType = "";
             file = Cursor.Location.File.ToString().Replace('/', '\\');
             if (System.IO.File.Exists(file))
             {
                 file = System.IO.Path.GetFileName(file);
             }
             typeHash = ComputeMd5(Cursor.Type);
             for (uint i = 0; i < Cursor.NumArguments; i++)
             {
                 Argument += ComputeMd5(Cursor.GetArgument(i));
             }
             ResultType = ComputeMd5(Cursor.ResultType);
             byte[] CursorData = Encoding.ASCII.GetBytes(Name + typeHash + file + Argument + ResultType);
             var    hash       = md5.ComputeHash(CursorData);
             return(BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant());
         }
         else
         {
             return("");
         }
     }
 }