Beispiel #1
0
        public string GetMethodType(DTOMethodPathsAction action)
        {
            var resp = action.Responses.First();

            if (resp != null)
            {
                var Schema = resp.Schema;
                if (Schema == null)
                {
                    return("");
                }
                else
                {
                    if (Schema.Items == null)
                    {
                        return(GetMethodTypeFromRef(Schema.TypeRef));
                    }
                    else
                    {
                        return("List<" + GetMethodTypeFromSchema(Schema.Items) + ">");
                    }
                }
            }
            return("");
        }
Beispiel #2
0
        List <DTOMethodPath> ParsePathDefs(JToken PathDefs)
        {
            var PathDefsList = new List <DTOMethodPath>();

            foreach (JProperty item in PathDefs)
            {
                try
                {
                    var Path = new DTOMethodPath();
                    Path.Actions = new List <DTOMethodPathsAction>();
                    Path.Path    = item.Name;
                    var StepIn = item.Value;
                    foreach (JProperty action in StepIn)
                    {
                        var Action = new DTOMethodPathsAction();
                        Action.ActionName = action.Name;
                        Action.Parameters = new List <DTOMethodPathsParameter>();
                        Action.Responses  = new List <DTOMethodPathsResponse>();

                        var            StepInAction = action.Value;
                        JsonSerializer serial       = new JsonSerializer();
                        serial.MetadataPropertyHandling = MetadataPropertyHandling.Ignore;
                        Action.Parameters = StepInAction["parameters"]?.ToObject <List <DTOMethodPathsParameter> >(serial);
                        foreach (JProperty resp in StepInAction["responses"])
                        {
                            JsonSerializerSettings settings = new JsonSerializerSettings();
                            settings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore;
                            var Response = resp.Value.ToObject <DTOMethodPathsResponse>(serial);
                            Response.StatusCode = resp.Name;
                            Action.Responses.Add(Response);
                        }


                        Path.Actions.Add(Action);
                    }

                    PathDefsList.Add(Path);
                }
                catch (Exception ex)
                {
                    int a = 3;
                }
            }
            return(PathDefsList);
        }
Beispiel #3
0
 public string GetMethodHead(DTOMethodPathsAction action, string path, string preClause = "")
 {
     try
     {
         string Head = "";
         Head += preClause;
         Head += "Task";
         var resp = action.Responses.First();
         if (resp != null)
         {
             var Schema = resp.Schema;
             if (Schema == null)
             {
                 Head += " " + GetMethodNameFromPath(path) + action.ActionName;
             }
             else
             {
                 if (Schema.Items == null)
                 {
                     Head += "<" + GetMethodTypeFromRef(Schema.TypeRef) + "> " + GetMethodNameFromPath(path) + action.ActionName;
                 }
                 else
                 {
                     Head += "<List<" + GetMethodTypeFromSchema(Schema.Items) + ">> " + GetMethodNameFromPath(path) + action.ActionName;
                 }
             }
         }
         Head += "(";
         Head += GetParamList(action.Parameters);
         Head += ")";
         return(Head);
     }
     catch (Exception)
     {
         return("");
     }
 }