Example #1
0
        /// <summary>
        /// Adds the necessary options for padding
        /// </summary>
        /// <param name="options">The Dictionary to add the options to</param>
        /// <param name="paddedSize">The size that the data section of the packet should be padded to. If throwExceptionOnNotEnoughPadding is true this must be at least the original data packet size plus four bytes</param>
        /// <param name="paddingType">Determines whether the data is padded with zeros or random data</param>
        /// <param name="throwExceptionOnNotEnoughPadding">If true an <see cref="ArgumentException"/> is thrown if paddingSize is smaller than the original data packet size plus four bytes</param>
        public static void AddPaddingOptions(Dictionary <string, string> options, int paddedSize, DataPaddingType paddingType = DataPaddingType.Zero, bool throwExceptionOnNotEnoughPadding = true)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            options[paddedSizeOptionName]   = paddedSize.ToString();
            options[padTypeOptionName]      = paddingType.ToString();
            options[padExceptionOptionName] = throwExceptionOnNotEnoughPadding.ToString();
        }
        /// <summary>
        /// Adds the necessary options for padding 
        /// </summary>
        /// <param name="options">The Dictionary to add the options to</param>
        /// <param name="paddedSize">The size that the data section of the packet should be padded to. If throwExceptionOnNotEnoughPadding is true this must be at least the original data packet size plus four bytes</param>        
        /// <param name="paddingType">Determines whether the data is padded with zeros or random data</param>
        /// <param name="throwExceptionOnNotEnoughPadding">If true an <see cref="ArgumentException"/> is thrown if paddingSize is smaller than the original data packet size plus four bytes</param>
        public static void AddPaddingOptions(Dictionary<string, string> options, int paddedSize, DataPaddingType paddingType = DataPaddingType.Zero, bool throwExceptionOnNotEnoughPadding = true)
        {
            if (options == null) throw new ArgumentNullException("options");

            options[paddedSizeOptionName] = paddedSize.ToString();
            options[padTypeOptionName] = paddingType.ToString();
            options[padExceptionOptionName] = throwExceptionOnNotEnoughPadding.ToString();
        }