コード例 #1
0
        public static EditServiceJson CreateFrom(PrimetonDescriptorViewModel model, JsonTemplateNames partName)
        {
            var serviceJson = new EditServiceJson
            {
                ServiceDescriptor = JsonConvert.SerializeObject(model),
                CurrentPath       = "",
                CurrentName       = partName
            };

            switch (partName)
            {
            case JsonTemplateNames.PrimetonParameter:
                serviceJson.CurrentJson = JsonConvert.SerializeObject(model.InputBody);
                break;

            case JsonTemplateNames.PrimetonReturn:
                serviceJson.CurrentJson = JsonConvert.SerializeObject(model.ReturnBody);
                break;

            default:
                throw new Exception("传入了非普元系统Web服务类型的部位参数" + partName.ToString());
            }

            return(serviceJson);
        }
コード例 #2
0
        public static EditServiceJson CreateFrom(SimpleRestfulDescriptorViewModel model, JsonTemplateNames partName)
        {
            var serviceJson = new EditServiceJson
            {
                ServiceDescriptor = JsonConvert.SerializeObject(model),
                CurrentPath       = "",
                CurrentName       = partName
            };

            switch (partName)
            {
            case JsonTemplateNames.RESTParameter:
                serviceJson.CurrentJson = JsonConvert.SerializeObject(model.JsonBodyTemplate);
                break;

            case JsonTemplateNames.RESTReturnValue:
                serviceJson.CurrentJson = JsonConvert.SerializeObject(model.ReturnJsonTemplate);
                break;

            default:
                throw new Exception("传入了非RESTful服务类型的部位参数" + partName.ToString());
            }

            return(serviceJson);
        }
コード例 #3
0
        public static EditServiceJson CreateFrom(EditServiceJsonViewModel model)
        {
            var serviceJson = new EditServiceJson
            {
                ServiceDescriptor = model.ServiceDescriptor,
                CurrentName       = model.CurrentName,
                CurrentPath       = model.CurrentPath,
                CurrentJson       = model.CurrentJson,
            };

            return(serviceJson);
        }
コード例 #4
0
 public EditServiceJsonViewModel(EditServiceJson serviceJson)
 {
     //ServiceType = serviceJson.ServiceType;
     ServiceDescriptor = serviceJson.ServiceDescriptor;
     CurrentName       = serviceJson.CurrentName;
     CurrentPath       = serviceJson.CurrentPath;
     CurrentJson       = serviceJson.CurrentJson;
     if (string.IsNullOrWhiteSpace(serviceJson.CurrentJson))
     {
         CurrentTemplate           = new JsonTemplate();
         CurrentTemplate.ValueType = ValueType.Integer;
     }
     else
     {
         CurrentTemplate = JsonConvert.DeserializeObject <JsonTemplate>(serviceJson.CurrentJson);
     }
 }
コード例 #5
0
 public static EditServiceJson CreateFrom(EsbService service, JsonTemplateNames partName)
 {
     if (service.Type == ServiceType.SimpleRESTful)
     {
         return(EditServiceJson.CreateFrom(SimpleRestfulDescriptorViewModel.CreateFrom(service), partName));
     }
     else if (service.Type == ServiceType.NCWebService)
     {
         return(EditServiceJson.CreateFrom(NCDescriptorViewModel.CreateFrom(service), partName));
     }
     else if (service.Type == ServiceType.PrimetonService)
     {
         return(EditServiceJson.CreateFrom(PrimetonDescriptorViewModel.CreateFrom(service), partName));
     }
     else
     {
         throw new Exception("not impleted service type");
     }
 }