Example #1
0
        private static async Task initGroups(string gender)
        {
            Task<string> task = RestAPI.callAsync(Facet.facetUrl, getFilter(gender));
            string json = await task;

            try
            {
                JsonArray root = JsonValue.Parse(json).GetArray();

                //TODO: this code should be async.
                groups = new Dictionary<string, List<Facet>>();
                for (uint i = 0; i < root.Count; i++)
                {
                    JsonObject obj = root.GetObjectAt(i);
                    FacetGroup data = new FacetGroup();
                    data = data.read(obj) as FacetGroup;
                    if (data == null)
                        continue;

                    groups.Add(data.GroupName, data.Items);
                }

            }
            catch (Exception e)
            {
                //TODO: add logging
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

        }
Example #2
0
        public override Data read(JsonObject obj)
        {
            FacetGroup facetGroup = new FacetGroup();
            Facet facet = new Facet();
            try
            {
                facetGroup.GroupName = obj.GetNamedString("filter");
                JsonArray root = obj.GetNamedArray(arrayName);

                facet.readList<Facet>(root, facetGroup.Items);
            }
            catch (Exception e)
            {
                //TODO: log exception
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            return facetGroup;
        }