Microsoft.Protocols.TestSuites.Common.RecipientRow.Size C# (CSharp) Method

Size() public method

Size of RecipientRow structure.
public Size ( ) : int
return int
        public int Size()
        {
            // For RecipientFlags
            this.size = sizeof(ushort);

            // For RecipientColumnCount
            this.size += sizeof(ushort);
            if ((ushort)TestSuites.Common.RecipientFlags.X500DN == (this.RecipientFlags & (ushort)TestSuites.Common.RecipientFlags.PersonalDistributionList2))
            {
                // For AddressPrefixUsed
                this.size++;

                // For DisplayType
                this.size++; 
            }

            if (((ushort)TestSuites.Common.RecipientFlags.PersonalDistributionList1 ==
                (this.RecipientFlags & (ushort)TestSuites.Common.RecipientFlags.PersonalDistributionList2))
                || ((ushort)TestSuites.Common.RecipientFlags.PersonalDistributionList2 ==
                (this.RecipientFlags & (ushort)TestSuites.Common.RecipientFlags.PersonalDistributionList2)))
            {
                // For EntryIdSize
                this.size += sizeof(ushort);

                // For SearchKeySize
                this.size += sizeof(ushort);
            }

            if (null != this.X500DN)
            {
                this.size += this.X500DN.Length;
            }

            if (null != this.EntryId)
            {
                this.size += this.EntryId.Length;
            }

            if (null != this.SearchKey)
            {
                this.size += this.SearchKey.Length;
            }

            if (null != this.AddressType)
            {
                this.size += this.AddressType.Length;
            }

            if (null != this.EmailAddress)
            {
                this.size += this.EmailAddress.Length;
            }

            if (null != this.DisplayName)
            {
                this.size += this.DisplayName.Length;
            }

            if (null != this.SimpleDisplayName)
            {
                this.size += this.SimpleDisplayName.Length;
            }

            if (null != this.TransmittableDisplayName)
            {
                this.size += this.TransmittableDisplayName.Length;
            }

            if (null != this.RecipientProperties)
            {
                // Flag of PropertyRow, one byte
                this.size++;

                if (null != this.RecipientProperties.PropertyValues)
                {
                    foreach (PropertyValue propertyValue in this.RecipientProperties.PropertyValues)
                    {
                        if (null != propertyValue.Value)
                        {
                            this.size += propertyValue.Value.Length;
                        }
                    }
                }
            }

            return this.size;
        }

Usage Example

        /// <summary>
        /// This method creates Sample RecipientColumns and Sample RecipientRows.
        /// </summary>
        /// <param name="recipientColumns">Sample RecipientColumns</param>
        /// <param name="recipientRows">Sample RecipientRows</param>
        protected void CreateSampleRecipientColumnsAndRecipientRows(out PropertyTag[] recipientColumns, out ModifyRecipientRow[] recipientRows)
        {
            // Step 1: Create Sample RecipientColumns.
            #region recipientColumns

            // The following sample data is from MS-OXCMSG 4.7.1.
            PropertyTag[] sampleRecipientColumns = new PropertyTag[12];
            sampleRecipientColumns[0] = this.propertyDictionary[PropertyNames.PidTagObjectType];
            sampleRecipientColumns[1] = this.propertyDictionary[PropertyNames.PidTagDisplayType];
            sampleRecipientColumns[2] = this.propertyDictionary[PropertyNames.PidTagAddressBookDisplayNamePrintable];
            sampleRecipientColumns[3] = this.propertyDictionary[PropertyNames.PidTagSmtpAddress];
            sampleRecipientColumns[4] = this.propertyDictionary[PropertyNames.PidTagSendInternetEncoding];
            sampleRecipientColumns[5] = this.propertyDictionary[PropertyNames.PidTagDisplayTypeEx];
            sampleRecipientColumns[6] = this.propertyDictionary[PropertyNames.PidTagRecipientDisplayName];
            sampleRecipientColumns[7] = this.propertyDictionary[PropertyNames.PidTagRecipientFlags];
            sampleRecipientColumns[8] = this.propertyDictionary[PropertyNames.PidTagRecipientTrackStatus];
            sampleRecipientColumns[9] = this.propertyDictionary[PropertyNames.PidTagRecipientResourceState];
            sampleRecipientColumns[10] = this.propertyDictionary[PropertyNames.PidTagRecipientOrder];
            sampleRecipientColumns[11] = this.propertyDictionary[PropertyNames.PidTagRecipientEntryId];
            recipientColumns = sampleRecipientColumns;

            #endregion

            // Step 2: Configure a StandardPropertyRow: propertyRow.
            #region Configure a StandardPropertyRow: propertyRow, data is from Page 62 of MS-OXCMSG

            PropertyValue[] propertyValueArray = new PropertyValue[12];
            for (int i = 0; i < propertyValueArray.Length; i++)
            {
                propertyValueArray[i] = new PropertyValue();
            }

            // PidTagObjectType
            propertyValueArray[0].Value = BitConverter.GetBytes(0x00000006);

            // PidTagDisplayType
            propertyValueArray[1].Value = BitConverter.GetBytes(0x00000000);

            // PidTa7BitDisplayName
            propertyValueArray[2].Value = Encoding.Unicode.GetBytes(Common.GetConfigurationPropertyValue("EmailAlias", this.Site) + "\0");

            // PidTagSmtpAddress
            propertyValueArray[3].Value = Encoding.Unicode.GetBytes(Common.GetConfigurationPropertyValue("EmailAlias", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site) + "\0");

            // PidTagSendInternetEncoding
            propertyValueArray[4].Value = BitConverter.GetBytes(0x00000000);

            // PidTagDisplayTypeEx
            propertyValueArray[5].Value = BitConverter.GetBytes(0x40000000);

            // PidTagRecipientDisplayName
            propertyValueArray[6].Value = Encoding.Unicode.GetBytes(Common.GetConfigurationPropertyValue("EmailAlias", this.Site) + "\0");

            // PidTagRecipientFlags
            propertyValueArray[7].Value = BitConverter.GetBytes(0x00000001);

            // PidTagRecipientTrackStatus
            propertyValueArray[8].Value = BitConverter.GetBytes(0x00000000);

            // PidTagRecipientResourceState
            propertyValueArray[9].Value = BitConverter.GetBytes(0x00000000);

            // PidTagRecipientOrder
            propertyValueArray[10].Value = BitConverter.GetBytes(0x00000000);

            // The following sample data (0x007c and the subsequent 124(0x7c) binary)
            // is copied from Page 62 of MS-OXCMSG
            byte[] sampleData = 
            { 
                0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0xa7, 0x40, 0xc8,
                0xc0, 0x42, 0x10, 0x1a, 0xb4, 0xb9, 0x08, 0x00, 0x2b, 0x2f,
                0xe1, 0x82, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x2f, 0x6f, 0x3d, 0x46, 0x69, 0x72, 0x73, 0x74, 0x20, 0x4f,
                0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f,
                0x6e, 0x2f, 0x6f, 0x75, 0x3d, 0x45, 0x78, 0x63, 0x68, 0x61,
                0x6e, 0x67, 0x65, 0x20, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x69,
                0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x47,
                0x72, 0x6f, 0x75, 0x70, 0x20, 0x28, 0x46, 0x59, 0x44, 0x49,
                0x42, 0x4f, 0x48, 0x46, 0x32, 0x33, 0x53, 0x50, 0x44, 0x4c,
                0x54, 0x29, 0x2f, 0x63, 0x6e, 0x3d, 0x52, 0x65, 0x63, 0x69,
                0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x63, 0x6e, 0x3d,
                0x75, 0x73, 0x65, 0x72, 0x32, 0x00 
            };

            // PidTagRecipientEntryId
            propertyValueArray[11].Value = sampleData;

            List<PropertyValue> propertyValues = new List<PropertyValue>();
            for (int i = 0; i < propertyValueArray.Length; i++)
            {
                propertyValues.Add(propertyValueArray[i]);
            }

            PropertyRow propertyRow = new PropertyRow
            {
                Flag = (byte)PropertyRowFlag.FlaggedPropertyRow,
                PropertyValues = propertyValues
            };

            // For propertyRow.Flag
            int tempLengthForTest = 1;
            foreach (PropertyValue pv in propertyRow.PropertyValues)
            {
                tempLengthForTest = tempLengthForTest + pv.Value.Length;
            }

            #endregion

            // Step 3: Create Sample RecipientRows.
            #region recipientRows

            RecipientRow recipientRow = new RecipientRow
            {
                // 0101 1001 0000 0110 S,D, Type=SMTP,I,U,E
                RecipientFlags = (ushort)(
                    RecipientFlags.SMTP
                    | RecipientFlags.S
                    | RecipientFlags.D
                    | RecipientFlags.I
                    | RecipientFlags.U
                    | RecipientFlags.E),

                // Set DisplayName, which specifies the Email Address of the recipient, as specified in [MS-OXCDATA].
                // This field is present because D is Set.
                DisplayName = Encoding.Unicode.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0"),

                // Set EmailAddress, which specifies the Email Address of the recipient,
                // as specified in [MS-OXCDATA].
                EmailAddress =
                    Encoding.Unicode.GetBytes(Common.GetConfigurationPropertyValue("EmailAlias", this.Site) + "@" +
                                              Common.GetConfigurationPropertyValue("Domain", this.Site) + "\0"),

                // Set SimpleDisplayName, which specifies the Email Address of the recipient,
                // as specified in [MS-OXCDATA].
                SimpleDisplayName =
                    Encoding.Unicode.GetBytes(Common.GetConfigurationPropertyValue("EmailAlias", this.Site) + "\0"),

                // Set RecipientColumnCount, which specifies the number of columns from the RecipientColumns field
                // that are included in RecipientProperties, as specified in [MS-OXCDATA].
                RecipientColumnCount = RecipientColumnCount,
                RecipientProperties = propertyRow
            };
            ModifyRecipientRow modifyRecipientRow = new ModifyRecipientRow
            {
                RowId = RowId, // Set RowId, which value specifies the ID of the recipient.
                RecipientType = (byte)RecipientType.PrimaryRecipient,
                RecipientRowSize = (ushort)recipientRow.Size(), // Set RecipientRowSize, which specifies the size of the RecipientRow field.
                RecptRow = recipientRow.Serialize()
            };
            ModifyRecipientRow[] sampleModifyRecipientRows = new ModifyRecipientRow[1];
            sampleModifyRecipientRows[0] = modifyRecipientRow;
            recipientRows = sampleModifyRecipientRows;

            #endregion
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.Common.RecipientRow::Size