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