Example #1
0
        public async Task <EntryDictionary <string, FileEntry> > ParseAsync(object apiResponse)
        {
            string json  = ParserResponseHelper.GetResponseString(apiResponse);
            var    files = await ParserHelper <EntryDictionary <string, FileEntry> > .ParseAsync(json).ConfigureAwait(false);

            return(files);
        }
        public Task <EntryDictionary <int, ColorEntry> > ParseAsync(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);

            return(Task.Run(async() =>
            {
                var temp = await ParserHelper <Dictionary <string, EntryDictionary <int, ColorEntry> > > .ParseAsync(json).ConfigureAwait(false);
                EntryDictionary <int, ColorEntry> colors = temp["colors"];
                foreach (var pair in colors)
                {
                    pair.Value.Id = pair.Key;
                    pair.Value.Cloth.Type = ColorItemType.Cloth;
                    pair.Value.Leather.Type = ColorItemType.Leather;
                    pair.Value.Metal.Type = ColorItemType.Metal;
                }
                if (colors == null)
                {
                    GwApi.Logger.Error("Failed parsing colors - {0}", Thread.CurrentContext.ContextID);
                }
                else
                {
                    GwApi.Logger.Info("Parsed {0} Colors - {1}", colors.Values.Count, Thread.CurrentContext.ContextID);
                }
                return colors;
            }));
        }
Example #3
0
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns></returns>
        public EntryDictionary <string, FileEntry> Parse(object apiResponse)
        {
            string json  = ParserResponseHelper.GetResponseString(apiResponse);
            var    files = ParserHelper <EntryDictionary <string, FileEntry> > .Parse(json);

            return(files);
        }
Example #4
0
        public async Task <EntryCollection <EventEntry> > ParseAsync(object apiResponse)
        {
            string json   = ParserResponseHelper.GetResponseString(apiResponse);
            var    events = await ParserHelper <EntryDictionary <string, EntryCollection <EventEntry> > > .ParseAsync(json).ConfigureAwait(false);

            return(events["events"]);
        }
        public async Task <IdList> ParseAsync(object apiResponse)
        {
            string json        = ParserResponseHelper.GetResponseString(apiResponse);
            var    recipesDict = await ParserHelper <Dictionary <string, List <int> > > .ParseAsync(json).ConfigureAwait(false);

            List <int> recipeIds = recipesDict["recipes"];

            return(new IdList(recipeIds));
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public EntryDictionary <string, MatchEntry> Parse(object apiResponse)
        {
            string json    = ParserResponseHelper.GetResponseString(apiResponse);
            var    entries = ParserHelper <Dictionary <string, EntryCollection <MatchEntry> > > .Parse(json)["wvw_matches"];

            var dict = entries.ToEntryDictionary(e => e.Id);

            return(dict);
        }
        public async Task <EntryDictionary <string, MatchEntry> > ParseAsync(object apiResponse)
        {
            string json    = ParserResponseHelper.GetResponseString(apiResponse);
            var    entries = await ParserHelper <Dictionary <string, EntryCollection <MatchEntry> > > .ParseAsync(json).ConfigureAwait(false);

            var dict = entries["wvw_matches"].ToEntryDictionary(e => e.Id);

            return(dict);
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public EntryDictionary <int, ObjectiveNameEntry> Parse(object apiResponse)
        {
            string json    = ParserResponseHelper.GetResponseString(apiResponse);
            var    entries = ParserHelper <EntryCollection <ObjectiveNameEntry> > .Parse(json);

            var dict = entries.ToEntryDictionary(e => e.Id);

            return(dict);
        }
        public async Task <EntryDictionary <int, ObjectiveNameEntry> > ParseAsync(object apiResponse)
        {
            string json    = ParserResponseHelper.GetResponseString(apiResponse);
            var    entries = await ParserHelper <EntryCollection <ObjectiveNameEntry> > .ParseAsync(json).ConfigureAwait(false);

            var dict = entries.ToEntryDictionary(e => e.Id);

            return(dict);
        }
        public async Task <IdList> ParseAsync(object apiResponse)
        {
            string json       = ParserResponseHelper.GetResponseString(apiResponse);
            var    itemIdDict = await ParserHelper <Dictionary <string, List <int> > > .ParseAsync(json);

            List <int> itemIds = itemIdDict["items"];

            return(new IdList(itemIds));
        }
Example #11
0
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public IdList Parse(object apiResponse)
        {
            string json        = ParserResponseHelper.GetResponseString(apiResponse);
            var    recipesDict = ParserHelper <Dictionary <string, List <int> > > .Parse(json);

            List <int> recipeIds = recipesDict["recipes"];

            return(new IdList(recipeIds));
        }
Example #12
0
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public RenderServiceAssetEntry Parse(object apiResponse)
        {
            byte[] rawBytes = ParserResponseHelper.GetResponseRaw(apiResponse);
            var    bitmap   = new Bitmap(new MemoryStream(rawBytes));

            return(new RenderServiceAssetEntry
            {
                Asset = bitmap,
            });
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public EntryDictionary <Guid, EventDetailsEntry> Parse(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);
            var    obj  = ParserHelper <Dictionary <string, EntryDictionary <Guid, EventDetailsEntry> > > .Parse(json);

            foreach (var pair in obj["events"])
            {
                pair.Value.EventId = pair.Key;
            }
            return(obj["events"]);
        }
Example #14
0
        public Task <RenderServiceAssetEntry> ParseAsync(object apiResponse)
        {
            byte[] rawBytes = ParserResponseHelper.GetResponseRaw(apiResponse);
            var    tsk      = new TaskCompletionSource <RenderServiceAssetEntry>();
            var    bitmap   = new Bitmap(new MemoryStream(rawBytes));

            tsk.TrySetResult(new RenderServiceAssetEntry
            {
                Asset = bitmap,
            });
            return(tsk.Task);
        }
        public async Task <EntryDictionary <Guid, EventDetailsEntry> > ParseAsync(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);
            var    obj  = await ParserHelper <Dictionary <string, EntryDictionary <Guid, EventDetailsEntry> > > .ParseAsync(json).ConfigureAwait(false);

            return(await Task.Run(() =>
            {
                foreach (var pair in obj["events"])
                {
                    pair.Value.EventId = pair.Key;
                }
                return obj["events"];
            }).ConfigureAwait(false));
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public EntryDictionary <int, MapEntry> Parse(object apiResponse)
        {
            string json  = ParserResponseHelper.GetResponseString(apiResponse);
            var    maps2 = ParserHelper <Dictionary <string, EntryDictionary <int, MapEntry> > > .Parse(json);

            if (maps2 != null)
            {
                var maps = maps2["maps"];
                foreach (var map in maps)
                {
                    map.Value.Id = map.Key;
                }
                return(maps);
            }
            return(new EntryDictionary <int, MapEntry>());
        }
        public async Task <EntryDictionary <int, MapEntry> > ParseAsync(object apiResponse)
        {
            string json  = ParserResponseHelper.GetResponseString(apiResponse);
            var    maps2 = await ParserHelper <Dictionary <string, EntryDictionary <int, MapEntry> > > .ParseAsync(json).ConfigureAwait(false);

            EntryDictionary <int, MapEntry> maps = null;

            if (maps2 != null)
            {
                maps = maps2["maps"];
                foreach (var map in maps)
                {
                    map.Value.Id = map.Key;
                }
            }
            return(maps ?? new EntryDictionary <int, MapEntry>());
        }
Example #18
0
        public async Task <MapFloorEntry> ParseAsync(object apiResponse)
        {
            string json       = ParserResponseHelper.GetResponseString(apiResponse);
            var    floorEntry = await ParserHelper <MapFloorEntry> .ParseAsync(json).ConfigureAwait(false);

            foreach (var region in floorEntry.Regions)
            {
                region.Value.Id = region.Key;
                foreach (var map in region.Value.Maps)
                {
                    map.Value.Id         = map.Key;
                    map.Value.RegionName = region.Value.Name;
                    map.Value.Id         = region.Value.Id;
                    foreach (var poi in region.Value.Maps)
                    {
                        poi.Value.Id = poi.Key;
                    }
                }
            }
            return(floorEntry);
        }
Example #19
0
        public MapFloorEntry Parse(object apiResponse)
        {
            string json       = ParserResponseHelper.GetResponseString(apiResponse);
            var    floorEntry = ParserHelper <MapFloorEntry> .Parse(json);

            foreach (var region in floorEntry.Regions)
            {
                region.Value.Id = region.Key;
                foreach (var map in region.Value.Maps)
                {
                    map.Value.Id         = map.Key;
                    map.Value.RegionName = region.Value.Name;
                    map.Value.Id         = region.Value.Id;
                    foreach (var poi in region.Value.Maps)
                    {
                        poi.Value.Id = poi.Key;
                    }
                }
            }
            return(floorEntry);
        }
Example #20
0
        /// <summary>
        /// Parse a json string containing an array of <seealso cref="EventEntry"/>
        /// </summary>
        /// <param name="apiResponse">json string containing an array</param>
        /// <returns>Collection of EventEntry objects</returns>
        public EntryCollection <EventEntry> Parse(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);
            EntryCollection <EventEntry> events = new EntryCollection <EventEntry>();
            JObject jo = JsonConvert.DeserializeObject(json) as JObject;

            if (jo != null)
            {
                foreach (var property in jo["events"])
                {
                    try
                    {
                        events.Add(Parse(property));
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e);
                        GwApi.Logger.Error(e);
                    }
                }
            }
            return(events);
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public EntryDictionary <int, ContinentEntry> Parse(object apiResponse)
        {
            string json       = ParserResponseHelper.GetResponseString(apiResponse);
            var    dictionary = ParserHelper <Dictionary <string, EntryDictionary <int, ContinentEntry> > > .Parse(json);

            try
            {
                var continents = dictionary["continents"];

                foreach (var pair in continents)
                {
                    pair.Value.Id = pair.Key;
                }
                GwApi.Logger.Info("Parsed {0} Colors", "ID:" + string.Join(",", continents.Keys));

                return(continents);
            }
            catch (Exception e)
            {
                GwApi.Logger.Error(e);
            }
            return(new EntryDictionary <int, ContinentEntry>());
        }
        public EntryDictionary <int, ColorEntry> Parse(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);
            var    temp = ParserHelper <Dictionary <string, EntryDictionary <int, ColorEntry> > > .Parse(json);

            EntryDictionary <int, ColorEntry> colors = temp["colors"];

            foreach (var pair in colors)
            {
                pair.Value.Id           = pair.Key;
                pair.Value.Cloth.Type   = ColorItemType.Cloth;
                pair.Value.Leather.Type = ColorItemType.Leather;
                pair.Value.Metal.Type   = ColorItemType.Metal;
            }
            if (colors == null)
            {
                GwApi.Logger.Error("Failed parsing colors");
            }
            else
            {
                GwApi.Logger.Info("Parsed {0} Colors", colors.Values.Count);
            }
            return(colors);
        }
        public async Task <EntryDictionary <int, ContinentEntry> > ParseAsync(object apiResponse)
        {
            string json       = ParserResponseHelper.GetResponseString(apiResponse);
            var    dictionary = await ParserHelper <Dictionary <string, EntryDictionary <int, ContinentEntry> > > .ParseAsync(json).ConfigureAwait(false);

            EntryDictionary <int, ContinentEntry> continents = null;

            try
            {
                continents = dictionary["continents"];

                foreach (var pair in continents)
                {
                    pair.Value.Id = pair.Key;
                }
                GwApi.Logger.Info("Parsed {0} Colors - {1}",
                                  "ID:" + string.Join(",", continents.Keys), Thread.CurrentContext.ContextID);
            }
            catch (Exception e)
            {
                GwApi.Logger.Error(e);
            }
            return(continents ?? new EntryDictionary <int, ContinentEntry>());
        }
        public ItemDetailsEntry Parse(object apiResponse)
        {
            string         json       = ParserResponseHelper.GetResponseString(apiResponse);
            JsonSerializer serializer = new JsonSerializer();

            using (TextReader reader = new StringReader(json))
            {
                using (JsonReader jreader = new JsonTextReader(reader))
                {
                    try
                    {
                        serializer.Converters.Add(new StringEnumConverter());
                        var itemDetails = serializer.Deserialize <ItemDetailsEntry>(jreader);
                        return(itemDetails);
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e);
                        GwApi.Logger.Error(e);
                    }
                    return(null);
                }
            }
        }
        public async Task <GuildDetailsEntry> ParseAsync(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);

            return(Verify(await ParserHelper <GuildDetailsEntry> .ParseAsync(json).ConfigureAwait(false), json));
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public GuildDetailsEntry Parse(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);

            return(Verify(ParserHelper <GuildDetailsEntry> .Parse(json), json));
        }
        /// <summary>
        /// Parses the response object.
        /// </summary>
        /// <param name="apiResponse">raw response from the GW2 Server</param>
        /// <returns>Parsed object</returns>
        public MatchDetailsEntry Parse(object apiResponse)
        {
            string json = ParserResponseHelper.GetResponseString(apiResponse);

            return(ParserHelper <MatchDetailsEntry> .Parse(json));
        }