Пример #1
0
        // Deserialization of Guid
        public static Guid DeserializeGuid(byte[] serializedData)
        {
            // Default value has byte 0 only
            if (serializedData.Length == 1 && serializedData[0] == 0)
            {
                return(Guid.Empty);
            }

            // Value different then default one
            return(BitToolkit.ConvertByteArrayToGuid(serializedData));
        }
Пример #2
0
        // Deserialization
        public Guid Deserialize()
        {
            // Read info about storage format
            GuidStorageFormats format = (GuidStorageFormats)SerializerStorage.ReadStorageFormatId(GuidStorageBase.FormatIdSizeInBits);

            // Is it default value
            if (format == GuidStorageFormats.DefaultValue)
            {
                return(Guid.Empty);
            }

            // Deserialize full data
            byte[] guidBytes = SerializerStorage.ReadPackedData(16); // 16 bytes
            return(BitToolkit.ConvertByteArrayToGuid(guidBytes));
        }