using System;
namespace IPA
{
internal enum EdgeLifecycleType
{
Enable, Disable
}
internal interface IEdgeLifecycleAttribute
{
EdgeLifecycleType Type { get; }
}
// TODO: is there a better way to manage this mess?
///
/// Indicates that the target method should be called when the plugin is enabled.
///
///
///
/// This attribute is interchangable with , and is treated identically.
/// They are seperate to allow plugin code to more clearly describe the intent of the methods.
///
///
/// Typically, this will be used when the parameter of the plugins's
/// is .
///
///
///
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class OnEnableAttribute : Attribute, IEdgeLifecycleAttribute
{
EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Enable;
}
///
/// Indicates that the target method should be called when the game starts.
///
///
///
/// This attribute is interchangable with , and is treated identically.
/// They are seperate to allow plugin code to more clearly describe the intent of the methods.
///
///
/// Typically, this will be used when the parameter of the plugins's
/// is .
///
///
///
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class OnStartAttribute : Attribute, IEdgeLifecycleAttribute
{
EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Enable;
}
///
/// Indicates that the target method should be called when the plugin is disabled.
///
///
///
/// This attribute is interchangable with , and is treated identically.
/// They are seperate to allow plugin code to more clearly describe the intent of the methods.
///
///
/// Typically, this will be used when the parameter of the plugins's
/// is .
///
///
///
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class OnDisableAttribute : Attribute, IEdgeLifecycleAttribute
{
EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Disable;
}
///
/// Indicates that the target method should be called when the game exits.
///
///
///
/// This attribute is interchangable with , and is treated identically.
/// They are seperate to allow plugin code to more clearly describe the intent of the methods.
///
///
/// Typically, this will be used when the parameter of the plugins's
/// is .
///
///
///
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class OnExitAttribute : Attribute, IEdgeLifecycleAttribute
{
EdgeLifecycleType IEdgeLifecycleAttribute.Type => EdgeLifecycleType.Disable;
}
}