Microsoft.Protocols.TestSuites.Common.PropertyTag.Serialize C# (CSharp) Method

Serialize() public method

Serialize the ROP request buffer.
public Serialize ( ) : byte[]
return byte[]
        public byte[] Serialize()
        {
            int index = 0;
            byte[] serializeBuffer = new byte[this.Size()];
            Array.Copy(BitConverter.GetBytes((ushort)this.PropertyType), 0, serializeBuffer, index, sizeof(ushort));
            index += sizeof(ushort);
            Array.Copy(BitConverter.GetBytes((ushort)this.PropertyId), 0, serializeBuffer, index, sizeof(ushort));
            index += sizeof(ushort);
            return serializeBuffer;
        }

Usage Example

        /// <summary>
        /// Serialize recipient properties.
        /// </summary>
        /// <returns>Serialized properties value.</returns>
        public static uint[] SerializeRecipientProperties()
        {
            uint[] aulPropTag = new uint[5];

            // PidTagEntryId
            PropertyTag propertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagEntryId,
                PropertyType = (ushort)PropertyType.PtypBinary
            };
            aulPropTag[0] = Common.ConvertByteArrayToUint(propertyTag.Serialize());

            // PidTagAddressType
            propertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagAddressType,
                PropertyType = (ushort)PropertyType.PtypString
            };
            aulPropTag[1] = Common.ConvertByteArrayToUint(propertyTag.Serialize());

            // PidTagEmailAddress
            propertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagEmailAddress,
                PropertyType = (ushort)PropertyType.PtypString
            };
            aulPropTag[2] = Common.ConvertByteArrayToUint(propertyTag.Serialize());

            // PidTagDisplayName
            propertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagDisplayName,
                PropertyType = (ushort)PropertyType.PtypString
            };
            aulPropTag[3] = Common.ConvertByteArrayToUint(propertyTag.Serialize());

            // PidTagSearchKey
            propertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagSearchKey,
                PropertyType = (ushort)PropertyType.PtypBinary
            };
            aulPropTag[4] = Common.ConvertByteArrayToUint(propertyTag.Serialize());
            return aulPropTag;
        }