using IPA.Loader.Features;
using IPA.Utilities;
using Mono.Cecil;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Version = SemVer.Version;
#if NET3
using Net3_Proxy;
#endif
namespace IPA.Loader
{
///
/// A class which describes a loaded plugin.
///
public class PluginMetadata
{
///
/// The assembly the plugin was loaded from.
///
/// the loaded Assembly that contains the plugin main type
public Assembly Assembly { get; internal set; }
///
/// The TypeDefinition for the main type of the plugin.
///
/// the Cecil definition for the plugin main type
public TypeDefinition PluginType { get; internal set; }
///
/// The human readable name of the plugin.
///
/// the name of the plugin
public string Name { get; internal set; }
///
/// The BeatMods ID of the plugin, or null if it doesn't have one.
///
/// the updater ID of the plugin
public string Id { get; internal set; }
///
/// The version of the plugin.
///
/// the version of the plugin
public Version Version { get; internal set; }
///
/// The file the plugin was loaded from.
///
/// the file the plugin was loaded from
public FileInfo File { get; internal set; }
// ReSharper disable once UnusedAutoPropertyAccessor.Global
///
/// The features this plugin requests.
///
/// the list of features requested by the plugin
public IReadOnlyList Features => InternalFeatures;
internal readonly List InternalFeatures = new List();
internal bool IsSelf;
///
/// Whether or not this metadata object represents a bare manifest.
///
/// if it is bare, otherwise
public bool IsBare { get; internal set; }
private PluginManifest manifest;
internal HashSet Dependencies { get; } = new HashSet();
internal PluginManifest Manifest
{
get => manifest;
set
{
manifest = value;
Name = value.Name;
Version = value.Version;
Id = value.Id;
}
}
///
/// The that the plugin specified in its .
///
public RuntimeOptions RuntimeOptions { get; internal set; }
///
/// Gets all of the metadata as a readable string.
///
/// the readable printable metadata string
public override string ToString() => $"{Name}({Id}@{Version})({PluginType?.FullName}) from '{Utils.GetRelativePath(File?.FullName, UnityGame.InstallPath)}'";
}
}