本文整理汇总了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;
}
});
}
示例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;
}
示例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;
}
});
}
示例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;
}
});
}