本文整理汇总了C#中Response.Format方法的典型用法代码示例。如果您正苦于以下问题:C# Response.Format方法的具体用法?C# Response.Format怎么用?C# Response.Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response.Format方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnReceiveResponse
public void OnReceiveResponse(Response response)
{
Trace.WriteLine("Response: " + response.Target);
Trace.WriteLine("Status: " + response.Status);
Trace.WriteLine(response.Format());
Trace.WriteLine("-".Multiply(80));
if (response.Status != 200) { // TODO: handle these
var errorMsg = (string)response["body"];
Console.WriteLine("error: " + errorMsg);
if (OnError != null)
OnError(response);
// If the error happens while initiating the session, close connection
if (stage != 4)
Connection.Close(errorMsg);
return;
}
if (stage == 1 && response.Target == "/authenticate1") {
var bbytes = (byte[])response["B"];
var salt = (byte[])response["salt"];
var user = (byte[])response["user"];
var userHash = Encoding.ASCII.GetString(user);
var password = FormatPassword();
var proof = srp.CalculateAuth1Proof(userHash, password, salt, bbytes);
Console.WriteLine("sending client proof: " + proof.Length);
var request = new Request("/authenticate2");
request["clientProof"] = proof;
stage = 2;
Connection.SendRequest(request);
} else if (stage == 2 && response.Target == "/authenticate2") {
Console.WriteLine("sending client proof2");
var request = new Request("/authenticate2");
request["clientProof"] = new byte[0];
stage = 3;
Connection.SendRequest(request);
} else if (stage == 3) {
if (OnSessionEstablished != null)
OnSessionEstablished();
stage = 4;
}
if (stage == 4) {
if (OnResponseReceived != null)
OnResponseReceived(response);
}
}
示例2: GetResponseAsync
private static async Task<Response<string>> GetResponseAsync(string relativeUriFormat, User user)
{
Response<string> response;
try
{
string dob = user.DateOfBirth.ToString("ddMMyyyy", System.Globalization.CultureInfo.InvariantCulture);
var postContent = new HttpFormUrlEncodedContent(
new KeyValuePair<string, string>[3] {
new KeyValuePair<string, string>("regno", user.RegNo),
new KeyValuePair<string, string>("dob", dob),
new KeyValuePair<string, string>("mobile", user.PhoneNo)
});
string uriString = BASE_URI_STRING + String.Format(relativeUriFormat, user.Campus);
HttpResponseMessage httpResponse = await _httpClient.PostAsync(new Uri(uriString), postContent);
response = await GetRootResponseAsync(httpResponse);
}
catch
{
response = new Response<string>(StatusCode.NoInternet, null);
}
return response.Format();
}