public VersionCheck(Manifest parent) : base(parent, parent.Mod.PackageId)
 {
     // start crunching those downloads
     FetchManifest(parent.manifestUri);
 }
Beispiel #2
0
        public static Manifest For(ModMetaData mod)
        {
            Manifest manifest;

            if (_manifestCache.TryGetValue(mod, out manifest))
            {
                return(manifest);
            }

            manifest     = new Manifest();
            manifest.mod = mod;

            // get from file.
            var manifestPath = Path.Combine(mod.AboutDir(), ManifestFileName);
            var modsyncPath  = Path.Combine(mod.AboutDir(), ModSyncFileName);

            // manifest is first choice
            if (File.Exists(manifestPath))
            {
                try
                {
                    manifest     = DirectXmlLoader.ItemFromXmlFile <Manifest>(manifestPath);
                    manifest.mod = mod;
                    manifest.dependencies.ForEach(d => d.Owner = manifest);
                    manifest.loadBefore.ForEach(d => d.Owner   = manifest);
                    manifest.loadAfter.ForEach(d => d.Owner    = manifest);
                    if (!manifest.manifestUri.NullOrEmpty())
                    {
                        try
                        {
                            manifest.ManifestUri = new Uri(manifest.manifestUri);
                        }
                        catch (Exception e)
                        {
                            Log.Warning($"Error parsing manifestUri: {e.Message}\n\n{e.StackTrace}");
                        }
                    }
                    if (!manifest.targetVersions.NullOrEmpty())
                    {
                        manifest.TargetVersions = new List <Version>();
                        foreach (var targetVersion in manifest.targetVersions)
                        {
                            manifest.TargetVersions.Add(manifest.ParseVersion(targetVersion));
                        }
                    }
                }
                catch (Exception e)
                {
                    manifest = new Manifest(mod);
                    Log.Error($"Error loading manifest for '{mod.Name}':\n{e.Message}\n\n{e.StackTrace}");
                }
            }

            // modsync manifest can provide some info
            else if (File.Exists(modsyncPath))
            {
                try
                {
                    ModSync modsync = DirectXmlLoader.ItemFromXmlFile <ModSync>(modsyncPath);
                    manifest = modsync.Manifest(mod);
                }
                catch (Exception e)
                {
                    manifest = new Manifest(mod);
                    Log.Error($"Error loading ModSync into manifest for '{mod.Name}': {e.Message}\n\n{e.StackTrace}");
                }
            }

            // resolve version - if set in manifest or modsync that takes priority,
            // otherwise try to read version from assemblies.
            manifest.SetVersion();
            _manifestCache.Add(mod, manifest);
            return(manifest);
        }
Beispiel #3
0
 public override void Notify_RecacheIssues()
 {
     _issues = null;
     Manifest?.Notify_RecacheIssues();
 }