private AnalyticsDataCollection(JObject obj) : base(obj) { // Get the column headers AnalyticsDataColumnHeader[] columns = obj.GetArray("columnHeaders", AnalyticsDataColumnHeader.Parse); Query = obj.GetObject("query", AnalyticsDataQuery.Parse); ItemsPerPage = obj.GetInt32("itemsPerPage"); TotalResults = obj.GetInt32("totalResults"); SelfLink = obj.GetString("selfLink"); PreviousLink = obj.GetString("nextLink"); NextLink = obj.GetString("previousLink"); ProfileInfo = obj.GetObject("profileInfo", AnalyticsProfileInfo.Parse); //ContainsSampledData = obj.GetBoolean("containsSampledData"); ColumnHeaders = columns; // TotalForAllResults = obj.GetBoolean("totalForAllResults"); Rows = AnalyticsDataRow.Parse(columns, obj.GetArray("rows")); }
internal static AnalyticsDataRow[] Parse(AnalyticsDataColumnHeader[] columnHeaders, JArray array) { // If the query returns no rows, the array will be NULL if (array == null) { return(new AnalyticsDataRow[0]); } // Initialize the array of rows with a fixed length based on the input array AnalyticsDataRow[] rows = new AnalyticsDataRow[array.Count]; // Iterate through each row for (int i = 0; i < array.Count; i++) { // Get the array of the row JArray row = array.GetArray(i); rows[i] = new AnalyticsDataRow { Index = i }; // Iterate through each cell for (int j = 0; j < row.Count; j++) { // Get the column header AnalyticsDataColumnHeader column = columnHeaders[j]; // Add the key and value to the dictionary rows[i]._cells.Add(column.Name, new AnalyticsDataCell { Row = rows[i], Index = j, Column = column, Value = row.GetString(j) }); // Set the array rows[i].Cells = rows[i]._cells.Values.ToArray(); } } return(rows); }