Attributes.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. namespace BepInEx
  3. {
  4. /// <summary>
  5. /// This attribute denotes that a class is a plugin, and specifies the required metadata.
  6. /// </summary>
  7. [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
  8. public class BepInPlugin : Attribute
  9. {
  10. /// <summary>
  11. /// The unique identifier of the plugin. Should not change between plugin versions.
  12. /// </summary>
  13. public string GUID { get; protected set; }
  14. /// <summary>
  15. /// The user friendly name of the plugin. Is able to be changed between versions.
  16. /// </summary>
  17. public string Name { get; protected set; }
  18. /// <summary>
  19. /// The specfic version of the plugin.
  20. /// </summary>
  21. public Version Version { get; protected set; }
  22. /// <param name="GUID">The unique identifier of the plugin. Should not change between plugin versions.</param>
  23. /// <param name="Name">The user friendly name of the plugin. Is able to be changed between versions.</param>
  24. /// <param name="Version">The specfic version of the plugin.</param>
  25. public BepInPlugin(string GUID, string Name, string Version)
  26. {
  27. this.GUID = GUID;
  28. this.Name = Name;
  29. this.Version = new Version(Version);
  30. }
  31. }
  32. /// <summary>
  33. /// This attribute specifies any dependencies that this plugin has on other plugins.
  34. /// </summary>
  35. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
  36. public class BepInDependency : Attribute
  37. {
  38. public enum DependencyFlags
  39. {
  40. /// <summary>
  41. /// The plugin has a hard dependency on the referenced plugin, and will not run without it.
  42. /// </summary>
  43. HardDependency = 1,
  44. /// <summary>
  45. /// This plugin has a soft dependency on the referenced plugin, and is able to run without it.
  46. /// </summary>
  47. SoftDependency = 2,
  48. }
  49. /// <summary>
  50. /// The GUID of the referenced plugin.
  51. /// </summary>
  52. public string DependencyGUID { get; protected set; }
  53. /// <summary>
  54. /// The flags associated with this dependency definition.
  55. /// </summary>
  56. public DependencyFlags Flags { get; protected set; }
  57. /// <param name="DependencyGUID">The GUID of the referenced plugin.</param>
  58. /// <param name="Flags">The flags associated with this dependency definition.</param>
  59. public BepInDependency(string DependencyGUID, DependencyFlags Flags = DependencyFlags.HardDependency)
  60. {
  61. this.DependencyGUID = DependencyGUID;
  62. this.Flags = Flags;
  63. }
  64. }
  65. /// <summary>
  66. /// This attribute specifies which processes this plugin should be run for. Not specifying this attribute will load the plugin under every process.
  67. /// </summary>
  68. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
  69. public class BepInProcess : Attribute
  70. {
  71. /// <summary>
  72. /// The name of the process that this plugin will run under.
  73. /// </summary>
  74. public string ProcessName { get; protected set; }
  75. /// <param name="ProcessName">The name of the process that this plugin will run under.</param>
  76. public BepInProcess(string ProcessName)
  77. {
  78. this.ProcessName = ProcessName;
  79. }
  80. }
  81. }