Beispiel #1
0
        private static void RegisterBadMods(ModInfoListPromiseArguments modInfoArgs, IDictionary <string, int> badMods)
        {
            foreach (var kv in modInfoArgs.ModInfo)
            {
                string            modName = kv.Key;
                BasicModInfoEntry modInfo = kv.Value;

                modInfo.IsBadMod = badMods.ContainsKey(modName);
            }
        }
Beispiel #2
0
        private static Tuple <IDictionary <string, BasicModInfoEntry>, bool> HandleModInfoReceipt(string output)
        {
            IDictionary <string, BasicModInfoEntry> modInfos = new Dictionary <string, BasicModInfoEntry>();

            JObject respJson = JObject.Parse(output);
            bool    found    = respJson.Count > 0;

            if (found)
            {
                JToken modListToken = respJson.SelectToken("modlist");
                if (modListToken == null)
                {
                    throw new NullReferenceException("No modlist");
                }

                JToken[] modList = modListToken.ToArray();

                foreach (JToken modEntry in modList)
                {
                    JToken modNameToken        = modEntry.SelectToken("name");
                    JToken modDisplaynameToken = modEntry.SelectToken("displayname");
                    JToken modAuthorToken      = modEntry.SelectToken("author");
                    JToken modVersRawToken     = modEntry.SelectToken("version");
                    //JToken modDescRawToken = modEntry.SelectToken( "hasdescription" );
                    //JToken modHomepageRawToken = modEntry.SelectToken( "homepage" );

                    if (modNameToken == null || modVersRawToken == null || modDisplaynameToken == null || modAuthorToken == null
                        /*|| hasDescRawToken == null || modHomepageRawToken == null*/)
                    {
                        continue;
                    }

                    string modName        = modNameToken.ToObject <string>();
                    string modDisplayName = modDisplaynameToken.ToObject <string>();
                    string modVersRaw     = modVersRawToken.ToObject <string>();
                    //string modDesc = modDescRawToken?.ToObject<string>() ?? null;
                    //string modHomepage = modHomepageRawToken.ToObject<string>();

                    Version modVers = Version.Parse(modVersRaw.Substring(1));
                    IEnumerable <string> modAuthors = modAuthorToken.ToObject <string>()
                                                      .Split(',')
                                                      .SafeSelect(a => a.Trim());

                    modInfos[modName] = new BasicModInfoEntry(modDisplayName, modAuthors, modVers, null, null);                          //modDesc, modHomepage
                }
            }

            return(Tuple.Create(modInfos, found));
        }