本文整理汇总了C#中System.Net.Response.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Response.ToString方法的具体用法?C# Response.ToString怎么用?C# Response.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Response
的用法示例。
在下文中一共展示了Response.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public HttpResponseMessage Get(string Method, string Ver = null, string Device = null, string Sid = null, string Md5 = null, int channel_id = 0, int start = 0, int end = 0, string group_id = null, string filter = null, int recording_id = 0, string name = null, int channel = 0, int time_t = 0, int duration = 0)
{
Logger.ServiceILog("Service Request: {0}, {1}", Method, Request.RequestUri.ToString());
object response = new Response() { ErrorCode = 0, ErrorMessage = "Unknown method." };
try
{
switch ((Method ?? "").ToLower())
{
case "session.initiate": response = Session_Initiate(Ver, Device); break;
case "session.login": response = Session_Login(Sid, Md5); break;
case "channel.icon": response = Channel_Icon(channel_id); break;
default:
{
var config = new Models.Configuration();
int userOid = 0;
if (config.EnableUserSupport) /* ensure a user is found if users are enabled */
{
if (!String.IsNullOrWhiteSpace(Sid) && SessionUserOids.ContainsKey(Sid))
userOid = SessionUserOids[Sid];
else
throw new UnauthorizedAccessException();
}
switch ((Method ?? "").ToLower())
{
case "setting.list": response = Setting_List(); break;
case "channel.listings": response = Channel_Listings(userOid, channel_id, start, end); break;
case "channel.list": response = Channel_List(userOid, group_id); break;
case "channel.groups": response = Channel_Groups(userOid); break;
case "recording.list": response = Recording_List(userOid, filter); break;
case "recording.delete": response = Recording_Delete(userOid, recording_id); break;
case "recording.save": response = Recording_Save(userOid, name, channel, time_t, duration); break;
}
}
break;
}
}
catch (InvalidSessionException)
{
response = new Response()
{
ErrorCode = 8,
ErrorMessage = "Invalid Session",
Stat = Response.ResponseStat.fail /* NOTE: this is a "fail" response */
};
}
catch (ChannelNotFoundException)
{
response = new Response()
{
ErrorCode = 5,
ErrorMessage = "Channel not found",
Stat = Response.ResponseStat.failed /* NOTE: this is a "fail" response */
};
}
if (response is Response)
return new HttpResponseMessage() { Content = new StringContent(response.ToString(), System.Text.Encoding.UTF8, "application/xml") };
else if (response == null)
return new HttpResponseMessage(HttpStatusCode.NotFound);
return response as HttpResponseMessage;
}