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


C# ServiceResponse.Serialize方法代码示例

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


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

示例1: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            String response = String.Empty;

            String operation = context.Request.QueryString["op"];
            String startRow = context.Request.QueryString["startRow"];
            String batchSize = context.Request.QueryString["batchSize"];
            String nameBankID = context.Request.QueryString["nameBankID"];
            String name = context.Request.QueryString["name"];
            String startDate = context.Request.QueryString["startDate"];
            String endDate = context.Request.QueryString["endDate"];
            String callback = context.Request.QueryString["callback"];
            String format = context.Request.QueryString["format"];

            OutputType outputType = OutputType.Xml;
            if (format == "json") outputType = OutputType.Json;

            try
            {
                if (String.Compare(operation, "NameCount", true) == 0)
                {
                    ServiceResponse<int> serviceResponse = new ServiceResponse<int>();
                    serviceResponse.NameResult = this.NameCount(startDate, endDate);
                    response = serviceResponse.Serialize(outputType);
                }
                else if (String.Compare(operation, "NameList", true) == 0)
                {
                    ServiceResponse<CustomGenericList<Name>> serviceResponse = new ServiceResponse<CustomGenericList<Name>>();
                    serviceResponse.NameResult = this.NameList(startRow, batchSize, startDate, endDate);
                    response = serviceResponse.Serialize(outputType);
                }
                else if (String.Compare(operation, "NameGetDetail", true) == 0)
                {
                    ServiceResponse<Name> serviceResponse = new ServiceResponse<Name>();
                    serviceResponse.NameResult = this.NameGetDetail(nameBankID);
                    response = serviceResponse.Serialize(outputType);
                }
                else if (String.Compare(operation, "NameSearch", true) == 0)
                {
                    ServiceResponse<CustomGenericList<Name>> serviceResponse = new ServiceResponse<CustomGenericList<Name>>();
                    serviceResponse.NameResult = this.NameSearch(name);
                    response = serviceResponse.Serialize(outputType);
                }
            }
            catch (Exception ex)
            {
                ServiceResponse<string> serviceResponse = new ServiceResponse<string>();
                serviceResponse.Status = "error";
                serviceResponse.ErrorMessage = ex.Message;
                serviceResponse.NameResult = ex.Message;
                response = serviceResponse.Serialize(outputType);
            }

            // Include any specified callback function in JSON responses
            if ((callback != null) && (callback != String.Empty) && outputType == OutputType.Json)
            {
                response = callback + "(" + response + ");";
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(response);
        }
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:62,代码来源:NameService.ashx.cs


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