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


C# Response.ToString方法代码示例

本文整理汇总了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;
 }
开发者ID:JonnyCam,项目名称:NextPvrWebConsole,代码行数:60,代码来源:ServiceController.cs


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