当前位置: 首页>>代码示例>>C#>>正文


C# MultipartFormDataContent.AddStringContent方法代码示例

本文整理汇总了C#中System.Net.Http.MultipartFormDataContent.AddStringContent方法的典型用法代码示例。如果您正苦于以下问题:C# MultipartFormDataContent.AddStringContent方法的具体用法?C# MultipartFormDataContent.AddStringContent怎么用?C# MultipartFormDataContent.AddStringContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.MultipartFormDataContent的用法示例。


在下文中一共展示了MultipartFormDataContent.AddStringContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAccount

        public Task<HSAccountResponse> CreateAccount(string emailAddress, string password)
        {
            var formData = new MultipartFormDataContent();
            if (!string.IsNullOrEmpty(emailAddress) && !string.IsNullOrEmpty(password))
            {
                formData.AddStringContent("email_address", emailAddress);
                formData.AddStringContent("password", password);
            }
            else
                throw new ArgumentNullException("emailAddress", "Both email address and password is required");

            return _httpClient.PostAsync(Config.CreateAccountUri, formData)
                .ContinueWith(t =>
                {
                    using (var sr = new StreamReader(t.Result.Content.ReadAsStreamAsync().Result))
                    using (var tr = new JsonTextReader(sr))
                    {
                        var resp = Serializer.Deserialize<HSAccountResponse>(tr);
                        return resp;
                    }
                });
        }
开发者ID:kwokhou,项目名称:HelloSignNet,代码行数:22,代码来源:HelloSignApiClient.cs

示例2: CreateFormData

        private MultipartFormDataContent CreateFormData(HSSendSignatureRequestData request)
        {
            var formData = new MultipartFormDataContent();

            if (!string.IsNullOrEmpty(request.Title))
                formData.AddStringContent("title", request.Title);
            if (!string.IsNullOrEmpty(request.Subject))
                formData.AddStringContent("subject", request.Subject);
            if (!string.IsNullOrEmpty(request.Message))
                formData.AddStringContent("message", request.Message);
            if (!string.IsNullOrEmpty(request.SigningRedirectUrl))
                formData.AddStringContent("signing_redirect_url", request.SigningRedirectUrl);

            for (var i = 0; i < request.Signers.Count; i++)
            {
                formData.AddStringContent(string.Format("signers[{0}][name]", i), request.Signers[i].Name);
                formData.AddStringContent(string.Format("signers[{0}][email_address]", i),
                    request.Signers[i].EmailAddress);
                if (!string.IsNullOrEmpty(request.Signers[i].Order))
                    formData.AddStringContent(string.Format("signers[{0}][order]", i), request.Signers[i].Order);
                if (!string.IsNullOrEmpty(request.Signers[i].Pin))
                    formData.AddStringContent(string.Format("signers[{0}][pin]", i), request.Signers[i].Pin);
            }

            for (var i = 0; request.CcEmailAddresses != null && i < request.CcEmailAddresses.Count; i++)
            {
                formData.AddStringContent(string.Format("cc_email_addresses[{0}]", i), request.CcEmailAddresses[i]);
            }

            for (var i = 0; request.Files != null && i < request.Files.Count; i++)
            {
                formData.AddFileStreamContent(i, request.Files[i].FullName, request.Files[i].Name);
            }

            for (var i = 0; request.FileUrls != null && i < request.FileUrls.Count; i++)
            {
                formData.AddStringContent(string.Format("file_url[{0}]", i), request.FileUrls[i]);
            }

            if (request.UseTextTags == 1)
                formData.AddStringContent("use_text_tags", "1");

            if (request.HideTextTags == 1)
                formData.AddStringContent("hide_text_tags", "1");

            formData.AddStringContent("test_mode", "1");

            return formData;
        }
开发者ID:kwokhou,项目名称:HelloSignNet,代码行数:49,代码来源:HelloSignApiClient.cs

示例3: VerifyAccount

        public Task<HSAccountResponse> VerifyAccount(string emailAddress)
        {
            var formData = new MultipartFormDataContent();
            if (!string.IsNullOrEmpty(emailAddress))
                formData.AddStringContent("email_address", emailAddress);

            return _httpClient.PostAsync(Config.VerifyAccountUri, formData)
                .ContinueWith(t =>
                {
                    using (var sr = new StreamReader(t.Result.Content.ReadAsStreamAsync().Result))
                    using (var tr = new JsonTextReader(sr))
                    {
                        var resp = Serializer.Deserialize<HSAccountResponse>(tr);
                        return resp;
                    }
                });
        }
开发者ID:kwokhou,项目名称:HelloSignNet,代码行数:17,代码来源:HelloSignApiClient.cs

示例4: UpdateAccount

        public Task<HSAccountResponse> UpdateAccount(string callbackUrl)
        {
            var formData = new MultipartFormDataContent();

            if (!string.IsNullOrEmpty(callbackUrl))
                formData.AddStringContent("callback_url", callbackUrl);

            return _httpClient.PostAsync(Config.UpdateAccountUri, formData)
                .ContinueWith(t =>
                {
                    using (var sr = new StreamReader(t.Result.Content.ReadAsStreamAsync().Result))
                    using (var tr = new JsonTextReader(sr))
                    {
                        var resp = Serializer.Deserialize<HSAccountResponse>(tr);
                        return resp;
                    }
                });
        }
开发者ID:kwokhou,项目名称:HelloSignNet,代码行数:18,代码来源:HelloSignApiClient.cs


注:本文中的System.Net.Http.MultipartFormDataContent.AddStringContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。