Permalink
Browse files

Readme

  • Loading branch information...
1 parent acdf657 commit ae677c38b08ad5791b8ba094160fa5357d4a2318 @Valve Valve committed Mar 5, 2014
Showing with 13 additions and 5 deletions.
  1. +13 −5 README.md
View
@@ -78,12 +78,12 @@ What does `Api#Execute` return?
It's a `Igooana.Result` object.
This object has two useful properties:
-1. `Values` property - an `IEnumerable<dynamic>`. This collection contains the results.
+1. `Values` property - an `IEnumerable<dynamic>`. This collection contains actual analytics data items.
Using `dynamic` allows you to have a collection of objects with all the properties you've queried with metrics and dimensions.
Moreover, all properties have their respective CLR types, not strings Google Analytics returns.
2. `Totals` property - a `dynamic`. This property contains the summed metrics. The names of totals directly correspond to the
-metrics you query.
+metrics you query. The properties have the correct CLR types, as with `Values`
`Totals` property example:
@@ -94,18 +94,26 @@ metrics you query.
.WithMetrics(Metric.Visits + Metric.Pageviews)
.WithDimensions(Dimension.Browser);
Result result = await api.Execute(query);
- Console.WriteLine("Total Visits: {0}, total page views: {1}", result.Totals.Visits, result.Totals.Pageviews);
+ Console.WriteLine("Total Visits: {0}, total page views: {1}",
+ result.Totals.Visits, result.Totals.Pageviews);
```
#### Potential caveat when using silverlight/windows phone data binding to `result.Values`:
There currently is a bug related to it: http://connect.microsoft.com/VisualStudio/feedback/details/522119/databinding-to-dynamic-objects-is-broken
-There are various workarounds listed on that issue page.
+There are various workarounds listed on that issue page.
+I'm using dynamic to anonymous object conversion:
+```c#
+
+Result resut = await api.Execute(query);
+var values = result.Values.Select(x => new {Visits = x.Visits, Pageviews = x.Pageviews});
+// now values can be safely data-bound in Silverlight/Windows Phone projects
+```
This is a work in progress, PRs are welcome :)
All code is MIT licensed
-_Valentin Vasilyev, 2013_
+_Valentin Vasilyev, 2014_

0 comments on commit ae677c3

Please sign in to comment.