public async Task ListJsonFiles()
        {
            var provider = new GithubDataProvider(
                RepoOption.Default_ToptoutDataUserRepo,
                PathOption.Default_ToptoutRepoPath);

            string url = await provider.FindDataFolderUrlAsync();

            var files = await provider.ListJsonFilesAsync(url);

            Assert.NotNull(url);

            Assert.NotNull(files);
            Assert.True(files.Count > 0);
        }
        public async Task LoadJsonFile()
        {
            var provider = new GithubDataProvider(
                RepoOption.Default_ToptoutDataUserRepo,
                PathOption.Default_ToptoutRepoPath);

            string url = await provider.FindDataFolderUrlAsync();

            var files = await provider.ListJsonFilesAsync(url);

            string jsonString = await provider.GetJsonFileAsString(files[0]);

            var t = JsonConvert.DeserializeObject <Toptout>(jsonString);

            Assert.NotNull(url);

            Assert.NotNull(files);
            Assert.True(files.Count > 0);
            Assert.False(string.IsNullOrEmpty(jsonString));
            Assert.NotNull(t);
        }
Exemple #3
0
        public async Task <IReadOnlyDictionary <string, Toptout> > ListTelemetryAsync()
        {
            Dictionary <string, Toptout> telemetry = new Dictionary <string, Toptout>();

            string url = await _provider.FindDataFolderUrlAsync();

            var files = await _provider.ListJsonFilesAsync(url);

            foreach (var appId in files)
            {
                try {
                    string jsonString = await _provider.GetJsonFileAsString(appId);

                    var t = JsonConvert.DeserializeObject <Toptout>(jsonString);

                    telemetry.Add(t.Id, t);
                }
                catch { }
            }

            return(telemetry.Count > 0 ? telemetry : null);
        }