コード例 #1
0
ファイル: GraphQLPublisher.cs プロジェクト: spuddybike/cogs
 public void IterateType(List <GraphQLItems> items, CogsModel model)
 {
     foreach (var data in model.ReusableDataTypes)
     {
         GraphQLItems type = new GraphQLItems();
         type.Type       = data.Name;
         type.Properties = new Dictionary <string, string>();
         GetExtendProp(type, data);
         foreach (var prop in data.Properties)
         {
             if (prop.MaxCardinality == "1")
             {
                 if (prop.DataType.Name == "double" || prop.DataType.Name == "decimal")
                 {
                     prop.DataType.Name = "Float";
                 }
                 type.Properties.Add(prop.Name, FirstCharToUpper(prop.DataType.Name));
             }
             else
             {
                 if (prop.DataType.Name == "double" || prop.DataType.Name == "decimal")
                 {
                     prop.DataType.Name = "Float";
                 }
                 type.Properties.Add(prop.Name, "[" + FirstCharToUpper(prop.DataType.Name) + "]");
             }
         }
         items.Add(type);
     }
     foreach (var data in model.ItemTypes)
     {
         GraphQLItems type = new GraphQLItems();
         type.Type       = data.Name;
         type.Properties = new Dictionary <string, string>();
         GetExtendProp(type, data);
         foreach (var prop in data.Properties)
         {
             if (prop.MaxCardinality == "1")
             {
                 if (prop.DataType.Name == "double" || prop.DataType.Name == "decimal")
                 {
                     prop.DataType.Name = "Float";
                 }
                 type.Properties.Add(prop.Name, FirstCharToUpper(prop.DataType.Name));
             }
             else
             {
                 if (prop.DataType.Name == "double" || prop.DataType.Name == "decimal")
                 {
                     prop.DataType.Name = "Float";
                 }
                 type.Properties.Add(prop.Name, "[" + FirstCharToUpper(prop.DataType.Name) + "]");
             }
         }
         items.Add(type);
     }
 }
コード例 #2
0
ファイル: GraphQLPublisher.cs プロジェクト: spuddybike/cogs
 public void GetExtendProp(GraphQLItems type, DataType data)
 {
     if (data.ExtendsTypeName != "")             //Check whether there it extends another class
     {
         //get the Parent information
         if (data.ParentTypes != null)
         {
             //traverse parent list, find the properties of the parents
             foreach (var properti in data.ParentTypes)
             {
                 if (properti.Properties != null)
                 {
                     //traverse the properties and get all the information regarding variable.
                     foreach (var inner_prop in properti.Properties)
                     {
                         if (inner_prop.MaxCardinality == "1")
                         {
                             if (inner_prop.DataType.Name == "double" || inner_prop.DataType.Name == "decimal")
                             {
                                 inner_prop.DataType.Name = "Float";
                             }
                             type.Properties.Add(inner_prop.Name, FirstCharToUpper(inner_prop.DataType.Name));
                         }
                         else
                         {
                             if (inner_prop.DataType.Name == "double" || inner_prop.DataType.Name == "decimal")
                             {
                                 inner_prop.DataType.Name = "Float";
                             }
                             type.Properties.Add(inner_prop.Name, "[" + FirstCharToUpper(inner_prop.DataType.Name) + "]");
                         }
                     }
                 }
             }
         }
     }
 }