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

EncodeGuid() public static méthode

Conversion of a GUID to a string representing the GUID
public static EncodeGuid ( System.Guid guid ) : string
guid System.Guid The GUID to convert
Résultat string
        public static string EncodeGuid(Guid guid)
        {
            uint[] num = new uint[6];
            char[] str = new char[22];
            int i, n;
            byte[] b = guid.ToByteArray();

            // Creation of six 32 Bit integers from the components of the GUID structure
            num[0] = (uint)(BitConverter.ToUInt32(b, 0) / 16777216);
            num[1] = (uint)(BitConverter.ToUInt32(b, 0) % 16777216);
            num[2] = (uint)(BitConverter.ToUInt16(b, 4) * 256 + BitConverter.ToInt16(b, 6) / 256);
            num[3] = (uint)((BitConverter.ToUInt16(b, 6) % 256) * 65536 + b[8] * 256 + b[9]);
            num[4] = (uint)(b[10] * 65536 + b[11] * 256 + b[12]);
            num[5] = (uint)(b[13] * 65536 + b[14] * 256 + b[15]);

            // Conversion of the numbers into a system using a base of 64
            n = 2;
            int pos = 0;
            for (i = 0; i < 6; i++)
            {
                cv_to_64(num[i], ref str, pos, n);
                pos += n; n = 4;
            }
            return new String(str);
        }

Usage Example

        protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
        {
            IfcObjectPlacement placement    = ObjectPlacement;
            JObject            placementObj = null;

            if (placement != null)
            {
                if (string.IsNullOrEmpty(placement.mGlobalId))
                {
                    placement.setGlobalId(ParserIfc.EncodeGuid(Guid.NewGuid()));
                }
                placementObj = placement.getJson(this, options);
            }
            base.setJSON(obj, host, options);

            if (placementObj != null)
            {
                obj["ObjectPlacement"] = placementObj;
            }
            if (options.Style != SetJsonOptions.JsonStyle.Repository)
            {
                IfcProductDefinitionShape representation = Representation;
                if (representation != null)
                {
                    obj["Representation"] = representation.getJson(this, options);
                }
            }
            //internal List<IfcRelAssignsToProduct> mReferencedBy = new List<IfcRelAssignsToProduct>();//	 :	SET OF IfcRelAssignsToProduct FOR RelatingProduct;
        }
All Usage Examples Of GeometryGym.Ifc.ParserIfc::EncodeGuid