Exemplo n.º 1
0
        void AddDataRow(IDictionary <string, JToken> root, JsonDataTable mainTable, int parentRowId, string parentTableName)
        {
            JsonDataRow row = new JsonDataRow(parentRowId);

            mainTable.Rows.Add(row);
            mainTable.AddFieldForMetadata("_Id", row._Id, true);
            mainTable.AddFieldForMetadata(parentTableName + "_Id", row._ParentId, true);

            foreach (var item in root)
            {
                if (item.Value is IDictionary <string, JToken> childDic)
                {
                    JsonDataTable childTable = AddNodeTable(childDic, item.Key, row._Id, mainTable.TableName);
                    mainTable.AddTable(item.Key, childTable);
                }
                else if (item.Value.HasValues)
                {
                    IEnumerable <JToken> childAry   = item.Value;
                    JsonDataTable        childTable = AddNodeTable(childAry, item.Key, row._Id, mainTable.TableName);
                    mainTable.AddTable(item.Key, childTable);
                }
                else
                {
                    mainTable.AddFieldForMetadata(item.Key, item.Value, false);
                    row.Fields.Add(new Field()
                    {
                        FieldName = item.Key, FieldValue = item.Value
                    });
                }
            }
        }
Exemplo n.º 2
0
 void AddDataRow(IEnumerable <JToken> arl, JsonDataTable table, int parentRowId, string parentTableName)
 {
     foreach (var item in arl)
     {
         if (item is IDictionary <string, JToken> childRecords)
         {
             AddDataRow(childRecords, table, parentRowId, parentTableName);
         }
         else if (item.HasValues)
         {
             // is IEnumerable<JToken> arlist
             //Don't know what to do here????
         }
         else if (item != null)  //For plain array
         {
             JsonDataRow row = new JsonDataRow(parentRowId);
             row.Fields.Add(new Field()
             {
                 FieldName = "Column1", FieldValue = item
             });
             table.Rows.Add(row);
             table.AddFieldForMetadata("_Id", row._Id, true);
             table.AddFieldForMetadata(parentTableName + "_Id", row._ParentId, true);
             table.AddFieldForMetadata("Column1", item, false);
         }
     }
 }
Exemplo n.º 3
0
 public void Add(JsonDataRow row)
 {
     if (!row.IsAddedInCollection)
     {
         _rowid++;
         row._Id = _rowid;
         rows.Add(row);
         row.IsAddedInCollection = true;
     }
 }