/// <summary>
        /// 添加文本内容到已有的Content
        /// 要求content-type为multipart/form-data
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="value">文本</param>
        /// <exception cref="NotSupportedException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        private void AddMulitpartTextInternal(string name, string value)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var httpContent = this.CastToMultipartContent();
            var textContent = new MulitpartTextContent(name, value);

            httpContent.Add(textContent);
            this.Content = httpContent;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加文本内容
        /// </summary>
        /// <param name="httpContent"></param>
        /// <param name="name">名称</param>
        /// <param name="value">文本</param>
        public static void AddText(this MultipartContent httpContent, string name, string value)
        {
            var textContent = new MulitpartTextContent(name, value);

            httpContent.Add(textContent);
        }