示例#1
0
        internal void RefreshJsonPaths()
        {
            dynamic versions = DownloadJsonFile(@"https://raw.githubusercontent.com/Shamshiel/DotA2StatsParser/master/DotA2StatsParser/Mapping/Version.json");

            string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            foreach (ParsingWebsites parsingWebsite in Enum.GetValues(typeof(ParsingWebsites)))
            {
                JsonPaths jsonPaths = GetLocalJsonPaths(currentVersion, parsingWebsite);

                Dictionary <string, Dictionary <string, string> > allVersionsDictionary = GetAllVersion(versions, parsingWebsite);

                Dictionary <string, string> urlDictioanry = null;

                if (allVersionsDictionary.ContainsKey(currentVersion))
                {
                    urlDictioanry = allVersionsDictionary[currentVersion];
                }
                else
                {
                    urlDictioanry = allVersionsDictionary.Last().Value;
                }

                if (urlDictioanry["IsDeprecated"] == "true")
                {
                    throw new Dota2StatParserException("This version was declared deprecated and will not work properly. Please update to a newer version!");
                }

                RefreshJsonFiles(jsonPaths, urlDictioanry);
            }
        }
示例#2
0
        internal DotabuffMappingController(JsonPaths jsonPaths)
        {
            JsonController jsonReader = new JsonController();
            GistClient     gistClient = new GistClient();


            var gistFiles = gistClient.GetGist("ebaba232180a83083cd1d9a2d7db65da");

            //dotabuffXPaths = jsonReader.ReadFromFile(jsonPaths.XPathsUri);
            dotabuffXPaths = jsonReader.ReadFromString(gistFiles["XPaths"].Content);


            //dotabuffQueryStrings = jsonReader.ReadFromFile(jsonPaths.QueryStringsUri);
            dotabuffQueryStrings = jsonReader.ReadFromString(gistFiles["QueryStrings"].Content);

            //dotabuffEnums = jsonReader.ReadFromFile(jsonPaths.EnumsUri);
            dotabuffEnums = jsonReader.ReadFromString(gistFiles["Enums"].Content);

            //dotabuffSelectors = jsonReader.ReadFromFile(jsonPaths.SelectorsUri);
            dotabuffSelectors = jsonReader.ReadFromString(gistFiles["Selectors"].Content);

            //dotabuffHtmlAttributes = jsonReader.ReadFromFile(jsonPaths.HtmlAttributesUri);
            dotabuffHtmlAttributes = jsonReader.ReadFromString(gistFiles["HtmlAttributes"].Content);

            //dotabuffUrls = jsonReader.ReadFromFile(jsonPaths.UrlsUri);
            dotabuffUrls = jsonReader.ReadFromString(gistFiles["Urls"].Content);
        }
示例#3
0
        private JsonPaths GetLocalJsonPaths(string version, ParsingWebsites parsingWebsite)
        {
            var paths = new JsonPaths()
            {
                EnumsUri          = string.Format(@"Mapping\{0}\{1}\Enums.json", parsingWebsite, version),
                QueryStringsUri   = string.Format(@"Mapping\{0}\{1}\QueryStrings.json", parsingWebsite, version),
                HtmlAttributesUri = string.Format(@"Mapping\{0}\{1}\HtmlAttributes.json", parsingWebsite, version),
                SelectorsUri      = string.Format(@"Mapping\{0}\{1}\Selectors.json", parsingWebsite, version),
                UrlsUri           = string.Format(@"Mapping\{0}\{1}\Urls.json", parsingWebsite, version),
                XPathsUri         = string.Format(@"Mapping\{0}\{1}\XPaths.json", parsingWebsite, version)
            };

            return(paths);
        }
示例#4
0
        private void RefreshJsonFiles(JsonPaths jsonPaths, Dictionary <string, string> urlDictioanry)
        {
            PropertyInfo[] propertyInfos = jsonPaths.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (string key in urlDictioanry.Keys)
            {
                foreach (PropertyInfo propertyInfo in propertyInfos)
                {
                    if (propertyInfo.Name.Contains(key))
                    {
                        string filePath = propertyInfo.GetValue(jsonPaths).ToString();
                        CreateFolderIfNotExist(filePath);

                        dynamic downloadedJsonObject = DownloadJsonFile(urlDictioanry[key]);
                        downloadedJsonObject.LastDownload = DateTime.Now;

                        RefreshJsonFile(filePath, downloadedJsonObject);
                    }
                }
            }
        }
        internal YaspMappingController(JsonPaths jsonPaths)
        {
            JsonController jsonReader = new JsonController();

            dotabuffUrls = jsonReader.ReadFromFile(jsonPaths.UrlsUri);
        }