Microsoft.Protocols.TestSuites.MS_OXORULE.AdapterHelper.ParsePermanentEntryIDFromBytes C# (CSharp) Method

ParsePermanentEntryIDFromBytes() public static method

Parse PermanentEntryID structure from byte array.
public static ParsePermanentEntryIDFromBytes ( byte bytes ) : PermanentEntryID
bytes byte The byte array to be parsed.
return PermanentEntryID
        public static PermanentEntryID ParsePermanentEntryIDFromBytes(byte[] bytes)
        {
            int index = 0;

            PermanentEntryID entryID = new PermanentEntryID
            {
                IDType = bytes[index++],
                R1 = bytes[index++],
                R2 = bytes[index++],
                R3 = bytes[index++],
                ProviderUID = new FlatUID_r
                {
                    Ab = new byte[Constants.FlatUIDByteSize]
                }
            };
            for (int i = 0; i < Constants.FlatUIDByteSize; i++)
            {
                entryID.ProviderUID.Ab[i] = bytes[index++];
            }

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

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

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