Exemplo n.º 1
0
        public CurseMod GetMod(string nameOrId)
        {
            var json = Call(nameOrId);
            // Check if the mod has been removed from Curse and if it corresponds to a KSP mod.
            var error = JsonConvert.DeserializeObject <CurseError>(json);

            if (!string.IsNullOrWhiteSpace(error.error))
            {
                throw new Kraken(string.Format(
                                     "Could not get the mod from Curse, reason: {0}.",
                                     error.message
                                     ));
            }
            return(CurseMod.FromJson(json));
        }
Exemplo n.º 2
0
        public CurseMod GetMod(int modId)
        {
            var json = Call(modId);

            // Check if the mod has been removed from Curse and if it corresponds to a KSP mod.
            var error = JsonConvert.DeserializeObject <CurseError>(json);

            if (error.code != 0)
            {
                var errorMessage = string.Format("Could not get the mod from Curse, reason: {0}.", error.message);
                throw new Kraken(errorMessage);
            }
            else if (!error.game.Equals("Kerbal Space Program"))
            {
                throw new Kraken("Could not get the mod from Curse, reason: Specified id is not a KSP mod");
            }

            return(CurseMod.FromJson(modId, json));
        }
Exemplo n.º 3
0
        public CurseMod GetMod(string nameOrId)
        {
            string json;

            try
            {
                json = Call(nameOrId);
            }
            catch (NativeAndCurlDownloadFailedKraken e)
            {
                // CurseForge returns a valid json with an error message in some cases.
                json = e.responseContent;
            }
            // Check if the mod has been removed from Curse and if it corresponds to a KSP mod.
            var error = JsonConvert.DeserializeObject <CurseError>(json);

            if (!string.IsNullOrWhiteSpace(error.error))
            {
                throw new Kraken($"Could not get the mod from Curse, reason: {error.message}.");
            }
            return(CurseMod.FromJson(json));
        }
Exemplo n.º 4
0
        public CurseMod GetMod(string nameOrId)
        {
            string json;

            try
            {
                json = Call(nameOrId);
            }
            catch (WebException e)
            {
                // CurseForge returns a valid json with an error message in some cases.
                json = new StreamReader(e.Response.GetResponseStream(), System.Text.Encoding.UTF8).ReadToEnd();
            }
            // Check if the mod has been removed from Curse and if it corresponds to a KSP mod.
            var error = JsonConvert.DeserializeObject <CurseError>(json);

            if (!string.IsNullOrWhiteSpace(error.error))
            {
                throw new Kraken($"Could not get the mod from Curse, reason: {error.message}.");
            }
            return(CurseMod.FromJson(json));
        }