GeometryGym.Ifc.ParserIfc.DecodeGlobalID C# (CSharp) Méthode

DecodeGlobalID() public static méthode

Reconstruction of the GUID from an IFC GUID string (base64)
public static DecodeGlobalID ( string guid ) : System.Guid
guid string The GUID string to convert. Must be 22 characters int
Résultat System.Guid
        public static Guid DecodeGlobalID(string guid)
        {
            try
            {
                if (guid.Length == 22)
                {
                    uint[] num = new uint[6];
                    char[] str = guid.ToCharArray();
                    int n = 2, pos = 0, i;
                    for (i = 0; i < 6; i++)
                    {
                        num[i] = cv_from_64(str, pos, n);
                        pos += n; n = 4;
                    }
                    int a = (int)((num[0] * 16777216 + num[1]));
                    short b = (short)(num[2] / 256);
                    short c = (short)((num[2] % 256) * 256 + num[3] / 65536);
                    byte[] d = new byte[8];
                    d[0] = Convert.ToByte((num[3] / 256) % 256);
                    d[1] = Convert.ToByte(num[3] % 256);
                    d[2] = Convert.ToByte(num[4] / 65536);
                    d[3] = Convert.ToByte((num[4] / 256) % 256);
                    d[4] = Convert.ToByte(num[4] % 256);
                    d[5] = Convert.ToByte(num[5] / 65536);
                    d[6] = Convert.ToByte((num[5] / 256) % 256);
                    d[7] = Convert.ToByte(num[5] % 256);

                    return new Guid(a, b, c, d);
                }
            }
            catch (Exception) { }
            return Guid.Empty;
        }