public static McModInfo ImportMcInfo(ISerializer <McModInfo> serializer, string modPath) { string modname = new DirectoryInfo(modPath).Name; string modInfoFilePath = ModPaths.McModInfoFile(modname).Replace("\\", "/"); string infoTextFormat = File.ReadAllText(modInfoFilePath); return(serializer.Deserialize(infoTextFormat)); }
public static McModInfo ImportMcInfo(string modPath) { McModInfoJsonConverter c = new McModInfoJsonConverter(); string modname = new DirectoryInfo(modPath).Name; string modInfoFilePath = ModPaths.McModInfoFile(modname).Replace("\\", "/"); string infoTextFormat = File.ReadAllText(modInfoFilePath); return(JsonConvert.DeserializeObject <McModInfo>(infoTextFormat, c)); }
public static void ExportMcInfo(McModInfo modInfo) { string modInfoPath = ModPaths.McModInfoFile(modInfo.Name); string serializedModInfo = JsonConvert.SerializeObject(modInfo, Formatting.Indented, new McModInfoJsonConverter()); using (StreamWriter writer = new StreamWriter(modInfoPath)) { writer.Write(serializedModInfo); } }
// 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)); }
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); }
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); }
// Writes to FmgModInfo file public static void ExportMod(ISerializer <McMod> serializer, McMod mcMod) => File.WriteAllText(ModPaths.FmgModInfoFile(mcMod.ModInfo.Name), serializer.Serialize(mcMod));
public static void ExportMcInfo(ISerializer <McModInfo> serializer, McModInfo modInfo) => File.WriteAllText(ModPaths.McModInfoFile(modInfo.Name), serializer.Serialize(modInfo));