示例#1
0
 internal void SetNode()
 {
     SyncStatic.TryCatch(() =>
     {
         if (NodePath.IsNullOrEmpty())
         {
             throw new Exception("请求地址不能为空!");
         }
         URI = new Uri(NodePath);
         if (!JsonParam.IsNullOrEmpty() && ReqType != MultiType.DELETE && ReqType != MultiType.GET)
         {
             Contents = new StringContent(JsonParam);
             Contents.Headers.ContentType = new MediaTypeHeaderValue("application/json");
         }
         if (!JsonParam.IsNullOrEmpty() && (ReqType == MultiType.DELETE || ReqType == MultiType.GET))
         {
             URI = new Uri(NodePath + JsonParam.ToModel <JObject>().ByUri());
         }
         if (FormParam != null && FormParam != null && FormParam.Count > 0 && ReqType != MultiType.DELETE && ReqType != MultiType.GET)
         {
             Contents = new FormUrlEncodedContent(FormParam);
             Contents.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
         }
         if (FormParam != null && FormParam != null && FormParam.Count > 0 && (ReqType == MultiType.DELETE || ReqType == MultiType.GET))
         {
             URI = new Uri(NodePath + FormParam.ByUri());
         }
         if (EntityParam != null && ReqType != MultiType.DELETE && ReqType != MultiType.GET)
         {
             Contents = new FormUrlEncodedContent(MultiKeyPairs.KeyValuePairs(EntityParam, MapFied));
             Contents.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
         }
         if (EntityParam != null && (ReqType == MultiType.DELETE || ReqType == MultiType.GET))
         {
             URI = new Uri(NodePath + EntityParam.ByUri());
         }
         MultiConfig.NodeOpt.Add(this);
     }, ex => throw ex);
 }