The PermanentEntryID structure identifies a specific object in the address book.
Esempio n. 1
0
        /// <summary>
        /// Parse PermanentEntryID structure from byte array.
        /// </summary>
        /// <param name="bytes">The byte array to be parsed.</param>
        /// <returns>An PermanentEntryID structure instance.</returns>
        public static PermanentEntryID ParsePermanentEntryIDFromBytes(byte[] bytes)
        {
            int index = 0;

            // The count size of the buffer
            uint size = BitConverter.ToUInt32(bytes, index);

            index += 4;

            PermanentEntryID entryID = new PermanentEntryID();

            entryID.IDType = bytes[index++];
            entryID.R1     = bytes[index++];
            entryID.R2     = bytes[index++];
            entryID.R3     = bytes[index++];
            byte[] bytesGUID = new byte[16];
            Array.Copy(bytes, index, bytesGUID, 0, 16);
            entryID.ProviderUID = new Guid(bytesGUID);
            index += 16;

            // R4: 4 bytes
            entryID.R4 = (uint)BitConverter.ToInt32(bytes, index);
            index     += 4;

            // DisplayType: 4 bytes
            entryID.DisplayTypeString = (DisplayTypeValues)BitConverter.ToInt32(bytes, index);
            index += 4;

            // DistinguishedName: variable
            entryID.DistinguishedName = System.Text.Encoding.Default.GetString(bytes, index, bytes.Length - index - 1);
            return(entryID);
        }
        /// <summary>
        /// Parse PermanentEntryID structure from byte array.
        /// </summary>
        /// <param name="bytes">The byte array to be parsed.</param>
        /// <returns>An PermanentEntryID structure instance.</returns>
        public static PermanentEntryID ParsePermanentEntryIDFromBytes(byte[] bytes)
        {
            int index = 0;

            // The count size of the buffer
            uint size = BitConverter.ToUInt32(bytes, index);
            index += 4;

            PermanentEntryID entryID = new PermanentEntryID();
            entryID.IDType = bytes[index++];
            entryID.R1 = bytes[index++];
            entryID.R2 = bytes[index++];
            entryID.R3 = bytes[index++];
            byte[] bytesGUID = new byte[16];
            Array.Copy(bytes, index, bytesGUID, 0, 16);
            entryID.ProviderUID = new Guid(bytesGUID);
            index += 16;

            // R4: 4 bytes
            entryID.R4 = (uint)BitConverter.ToInt32(bytes, index);
            index += 4;

            // DisplayType: 4 bytes
            entryID.DisplayTypeString = (DisplayTypeValues)BitConverter.ToInt32(bytes, index);
            index += 4;

            // DistinguishedName: variable 
            entryID.DistinguishedName = System.Text.Encoding.Default.GetString(bytes, index, bytes.Length - index - 1);
            return entryID;
        }