예제 #1
0
        public static CurseMod FromJson(string json)
        {
            CurseMod mod = JsonConvert.DeserializeObject <CurseMod>(json);

            foreach (CurseFile file in mod.files)
            {
                file.ModPageUrl = mod.GetPageUrl();
            }
            return(mod);
        }
예제 #2
0
파일: CurseMod.cs 프로젝트: zakipatel/CKAN
        public static CurseMod FromJson(int modId, string json)
        {
            CurseMod mod = JsonConvert.DeserializeObject <CurseMod>(json);

            mod.ModId = modId;
            foreach (CurseFile file in mod.files.Values)
            {
                file.Mod = mod;
            }
            return(mod);
        }
예제 #3
0
파일: CurseApi.cs 프로젝트: zilti/CKAN
        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));
        }
예제 #4
0
파일: CurseApi.cs 프로젝트: zakipatel/CKAN
        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));
        }
예제 #5
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));
        }
예제 #6
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));
        }