Exemplo n.º 1
0
 /// <summary>
 /// Casts the current GUID to a <see cref="GlobalUniqueId"/>
 /// </summary>
 /// <param name="id">The IFC GUID</param>
 /// <param name="asGuid">Whether to cast to GUID</param>
 /// <returns></returns>
 public static GlobalUniqueId ToGlobalUniqueId(this IfcGloballyUniqueId id, bool asGuid = false)
 {
     if (asGuid)
     {
         var guid = IfcGloballyUniqueId.ConvertFromBase64(id);
         return(new GlobalUniqueId
         {
             Guid = new Bitub.Dto.Guid
             {
                 Raw = Google.Protobuf.ByteString.CopyFrom(guid.ToByteArray())
             }
         });
     }
     else
     {
         return(new GlobalUniqueId
         {
             Base64 = id
         });
     }
 }
Exemplo n.º 2
0
        private IfcGloballyUniqueId GetGuid(string guid)
        {
            IfcGloballyUniqueId IfcGlobalId;

            try
            {
                //Assume, that is is a UUID based on IETF RFC 4122
                IfcGlobalId = IfcGloballyUniqueId.ConvertToBase64(Guid.Parse(guid));
            }
            catch
            {
                try
                {
                    //Assume, that is is already an IFC compliant IfcGloballyUniqueId
                    IfcGlobalId = IfcGloballyUniqueId.ConvertFromBase64(guid);
                }
                catch
                {
                    //Generate a new GUID every time
                    IfcGlobalId = IfcGloballyUniqueId.ConvertToBase64(Guid.NewGuid());
                }
            }
            return(IfcGlobalId);
        }