Microsoft.Protocols.TestSuites.MS_OXORULE.AddressBookEntryID.Serialize C# (CSharp) Method

Serialize() public method

Get serialized byte array for this struct
public Serialize ( ) : byte[]
return byte[]
        public byte[] Serialize()
        {
            List<byte> bytes = new List<byte>();
            bytes.AddRange(BitConverter.GetBytes(this.Flags));
            bytes.AddRange(this.ProviderUID);
            bytes.AddRange(BitConverter.GetBytes(this.Version));
            bytes.AddRange(BitConverter.GetBytes((uint)this.Type));
            bytes.AddRange(Encoding.ASCII.GetBytes(this.valueOfX500DN + "\0"));
            return bytes.ToArray();
        }

Usage Example

        /// <summary>
        /// Generate property value on recipient.
        /// </summary>
        /// <param name="userName">Recipient user name.</param>
        /// <param name="userDN">Recipient user dn.</param>
        /// <returns>Property array value.</returns>
        public static TaggedPropertyValue[] GenerateRecipientPropertiesBlock(string userName, string userDN)
        {
            TaggedPropertyValue[] recipientProperties = new TaggedPropertyValue[4];

            // Add PidTagDisplayName
            recipientProperties[0] = new TaggedPropertyValue();

            PropertyTag pidTagDisplayNamePropertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagDisplayName,
                PropertyType = (ushort)PropertyType.PtypString
            };
            recipientProperties[0].PropertyTag = pidTagDisplayNamePropertyTag;
            recipientProperties[0].Value = Encoding.Unicode.GetBytes(userName + "\0");

            // Add PidTagEmailAddress
            recipientProperties[1] = new TaggedPropertyValue();
            PropertyTag pidTagEmailAddressPropertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagEmailAddress,
                PropertyType = (ushort)PropertyType.PtypString
            };
            recipientProperties[1].PropertyTag = pidTagEmailAddressPropertyTag;
            recipientProperties[1].Value = Encoding.Unicode.GetBytes(userDN + "\0");

            // Add PidTagRecipientType
            recipientProperties[2] = new TaggedPropertyValue();
            PropertyTag pidTagRecipientTypePropertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagRecipientType,
                PropertyType = (ushort)PropertyType.PtypInteger32
            };
            recipientProperties[2].PropertyTag = pidTagRecipientTypePropertyTag;
            recipientProperties[2].Value = BitConverter.GetBytes(0x00000001);

            AddressBookEntryID addressBookEntryID = new AddressBookEntryID(userDN);

            // Add PidTagEntryID
            recipientProperties[3] = new TaggedPropertyValue();
            PropertyTag pidTagEntryIDPropertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagEntryId,
                PropertyType = (ushort)PropertyType.PtypBinary
            };
            recipientProperties[3].PropertyTag = pidTagEntryIDPropertyTag;
            recipientProperties[3].Value = Common.AddInt16LengthBeforeBinaryArray(addressBookEntryID.Serialize());

            return recipientProperties;
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_OXORULE.AddressBookEntryID::Serialize