コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
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));
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
 // Writes to FmgModInfo file
 public static void ExportMod(ISerializer <McMod> serializer, McMod mcMod) => File.WriteAllText(ModPaths.FmgModInfoFile(mcMod.ModInfo.Name), serializer.Serialize(mcMod));
コード例 #8
0
 public static void ExportMcInfo(ISerializer <McModInfo> serializer, McModInfo modInfo) => File.WriteAllText(ModPaths.McModInfoFile(modInfo.Name), serializer.Serialize(modInfo));