Esempio n. 1
0
        // Writes to FmgModInfo file
        public static void ExportMod(Mod mod)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.All
            };

            settings.Converters.Add(new ModJsonConverter());
            settings.Converters.Add(new McModInfoJsonConverter());
            settings.Converters.Add(new ForgeVersionJsonConverter());
            File.WriteAllText(ModPaths.FmgModInfoFile(mod.ModInfo.Name), JsonConvert.SerializeObject(mod, settings));
        }
Esempio n. 2
0
        public static McMod ImportMod(ISerializer <McMod> serializer, string modPath)
        {
            string fmgModInfoPath = ModPaths.FmgModInfoFile(new DirectoryInfo(modPath).Name);

            try
            {
                return(serializer.Deserialize(File.ReadAllText(fmgModInfoPath)));
            }
            catch (System.Exception ex)
            {
                Log.Error(ex, $"Failed to load: {fmgModInfoPath}");
            }
            return(null);
        }
Esempio n. 3
0
        public static Mod ImportMod(string modPath)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.All
            };

            settings.Converters.Add(new ModJsonConverter());
            settings.Converters.Add(new McModInfoJsonConverter());
            settings.Converters.Add(new ForgeVersionJsonConverter());
            string fmgModInfoPath = ModPaths.FmgModInfoFile(new DirectoryInfo(modPath).Name);

            try
            {
                return(JsonConvert.DeserializeObject <Mod>(File.ReadAllText(fmgModInfoPath), settings));
            }
            catch (System.Exception ex)
            {
                Log.Error(ex, $"Failed to load: {fmgModInfoPath}");
            }
            return(null);
        }
Esempio n. 4
0
 // Writes to FmgModInfo file
 public static void ExportMod(ISerializer <McMod> serializer, McMod mcMod) => File.WriteAllText(ModPaths.FmgModInfoFile(mcMod.ModInfo.Name), serializer.Serialize(mcMod));