public static void BeginReading(string filePath)
 {
     if (xdoc != null || string.IsNullOrEmpty(CurrnetUsingFilePath))
     {
         Log.Warning("xdoc is still open. force-closing");
         xdoc = null;
         CurrnetUsingFilePath = null;
     }
     SimpleLog.Log($"Trying to load {filePath}");
     xdoc = XDocument.Load(filePath);
     CurrnetUsingFilePath = filePath;
 }
        static void RebuildVersionDict()
        {
            SimpleLog.Log("Rebuilding VersionDict");
            isVersionDictDirty = false;
            versionDict.Clear();

            if (xdoc == null)
            {
                Log.Error($"invoke BeginReading before calling {nameof(RebuildVersionDict)}");
                return;
            }

            try
            {
                var ModMetaHeaders = xdoc.Root.Element("meta")?.Element(MOD_META_DATAS);
                if (ModMetaHeaders == null)
                {
                    return;
                }

                var elements = ModMetaHeaders.Elements();
                foreach (var node in elements)
                {
                    var Identifier = node.Element(MOD_IDENTIFIER_NODENAME)?.Value;
                    var Version    = node.Element(VERSION_NODENAME)?.Value;

                    if (Identifier == null || Version == null) // variable sanity check
                    {
                        continue;
                    }

                    versionDict[Identifier] = Version;

                    SimpleLog.Log($"Set {Identifier} {Version}");
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Exception while rebuilding VersionDict, exception : {ex.Message}");
                return;
            }
        }
        public static void UpdateModVersionMetaHeader()
        {
            string rawFilePath = SaveFilePathCache;
            string filePath    = GenFilePaths.FilePathForSavedGame(rawFilePath);

            MetaHeaderUtility.BeginReading(filePath);
            List <ModMetaHeader> metaHeaders = new List <ModMetaHeader>();

            foreach (var modContentPack in LoadedModManager.RunningMods)
            {
                // var metadata = modContentPack.GetMetaData();
                var version = MetaHeaderUtility.GetVersionFromManifestFile(modContentPack);
                metaHeaders.Add(new ModMetaHeader()
                {
                    Identifier = modContentPack.PackageId, Version = version
                });
                SimpleLog.Log($"Add metadata to metaHeaders list : {modContentPack.PackageId}, {version}");
            }
            MetaHeaderUtility.SetVersions(metaHeaders);
            MetaHeaderUtility.EndReading();
        }