将类名传递给方法

时间:2015-02-17 06:45:28

标签: c# json oop windows-runtime windows-phone

我正在编写Windows Phone 8.1应用程序(WINRT)。我必须调用 HTTPHandlerMethod 方法接受三个参数。我将服务器API地址作为字符串 JsonString传递给服务器作为字符串,我还需要将类名发送到HTTPHandlerMethod作为字符串第三个参数。如何发送班级名称?我实际上需要在JSON DeSerializing中使用此方法中的类名:

  

JsonConvert.DeserializeObject(JSonData_Recieved,CLASS NAME HERE);

 public async void HTTPHandlerMethod(string AddressPath,
    string JSonData_ToSend, **WHAT THIRD PARAMETER TO WRITE HERE??**)
 {
     Object resObject = null;
     HttpBaseProtocolFilter HttpBaseProtocolFilterObject = new HttpBaseProtocolFilter();
     HttpClient HttpClientObject = new HttpClient(HttpBaseProtocolFilterObject);

     string CompleteAddress = singletonInstance.APIServer + AddressPath;
     Uri UriObject = new Uri(CompleteAddress);
     HttpRequestMessage HttpRequestMessageObject = 
        new HttpRequestMessage(HttpMethod.Post, UriObject);

     HttpRequestMessageObject.Content = new HttpStringContent(JSonData_ToSend,
           Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");

     try
     {
       HttpResponseMessage HttpResponseMessageObject = 
              await HttpClientObject.SendRequestAsync(HttpRequestMessageObject,
                   HttpCompletionOption.ResponseContentRead);

       if (HttpResponseMessageObject.IsSuccessStatusCode)  //If 2xx success is recieved
       {
          string JSonData_Recieved = 
             await HttpResponseMessageObject.Content.ReadAsStringAsync();
         resObject = JsonConvert.DeserializeObject(JSonData_Recieved,resType);
        }
     }
     catch  { }
   }
 }

我应该对此 HTTPHandlerMethod 方法做些什么修改?以及如何调用呢?

1 个答案:

答案 0 :(得分:0)

 public async void HTTPHandlerMethod(string AddressPath,
    string JSonData_ToSend, Type classname)
 {

}