Exemple #1
0
 private async Task <String> ReadSplit(Int32 subpage)
 {
     return((await SubredditWiki.GetPageAsync(PageName + "/" + subpage.ToString())).MarkdownContent);
 }
Exemple #2
0
 private async Task WriteSplit(String portion, Int32 subpage)
 {
     await SubredditWiki.EditPageAsync(PageName + "/" + subpage.ToString(), portion);
 }
Exemple #3
0
        public override async Task <BanListConfig> ReadConfigAsync()
        {
            WikiSplitConfig meta = JsonConvert.DeserializeObject <WikiSplitConfig>((await SubredditWiki.GetPageAsync(PageName)).MarkdownContent);

            meta.ValidateSupportedVersion(1, 1);
            IList <Task <String> > tasks = new List <Task <String> >();

            for (int i = 1; i <= meta.Pages; i++)
            {
                tasks.Add(ReadSplit(i));
            }
            await Task.WhenAll(tasks);

            StringBuilder sb = new StringBuilder();

            foreach (Task <String> configPageTask in tasks)
            {
                if (configPageTask.IsFaulted)
                {
                    throw new ConfigurationException("Failed to load subpage from wiki", configPageTask.Exception);
                }
                sb.Append(configPageTask.Result);
            }
            BanListConfig config = JsonConvert.DeserializeObject <BanListConfig>(sb.ToString());

            config.ValidateSupportedVersion(2, 2);
            return(config);
        }