Exemple #1
0
        public static async Task <List <ModlistMetadata> > LoadFromGithub()
        {
            var client = new Http.Client();

            Utils.Log("Loading ModLists from GitHub");
            var metadataResult = client.GetStringAsync(Consts.ModlistMetadataURL);
            var utilityResult  = client.GetStringAsync(Consts.UtilityModlistMetadataURL);
            var summaryResult  = client.GetStringAsync(Consts.ModlistSummaryURL);

            var metadata = (await metadataResult).FromJsonString <List <ModlistMetadata> >();

            metadata = metadata.Concat((await utilityResult).FromJsonString <List <ModlistMetadata> >()).ToList();
            try
            {
                var summaries = (await summaryResult).FromJsonString <List <ModListSummary> >().ToDictionary(d => d.MachineURL);

                foreach (var data in metadata)
                {
                    if (summaries.TryGetValue(data.Links.MachineURL, out var summary))
                    {
                        data.ValidationSummary = summary;
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            return(metadata.OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0, m.Title)).ToList());
        }
Exemple #2
0
 public static async Task <List <ModlistMetadata> > LoadUnlistedFromGithub()
 {
     try
     {
         var client = new Http.Client();
         return((await client.GetStringAsync(Consts.UnlistedModlistMetadataURL)).FromJsonString <List <ModlistMetadata> >());
     }
     catch (Exception)
     {
         Utils.LogStatus("Error loading unlisted modlists");
         return(new List <ModlistMetadata>());
     }
 }
Exemple #3
0
        public static async Task <List <ModlistMetadata> > LoadFromGithub()
        {
            var client = new Http.Client();

            Utils.Log("Loading ModLists from GitHub");
            var metadataResult = client.GetStringAsync(Consts.ModlistMetadataURL);
            var utilityResult  = client.GetStringAsync(Consts.UtilityModlistMetadataURL);
            var summaryResult  = client.GetStringAsync(Consts.ModlistSummaryURL);

            var metadata = (await metadataResult).FromJsonString <List <ModlistMetadata> >();

            metadata = metadata.Concat((await utilityResult).FromJsonString <List <ModlistMetadata> >()).ToList();
            try
            {
                var summaries = (await summaryResult).FromJsonString <List <ModListSummary> >().ToDictionary(d => d.MachineURL);

                foreach (var data in metadata)
                {
                    if (summaries.TryGetValue(data.Links.MachineURL, out var summary))
                    {
                        data.ValidationSummary = summary;
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            var random = new Random();

            return(metadata
                   // Sort randomly initially, just to give each list a fair shake
                   .Shuffle(random)
                   // Put broken lists at bottom
                   .OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0))
                   .ToList());
        }