46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace VDash.Overlay.Actions
|
|
{
|
|
public interface IOverlayAction
|
|
{
|
|
void PreformAction(IOverlay overlay);
|
|
bool Enabled { get; set; }
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
|
public class OverlayActionInfo : System.Attribute
|
|
{
|
|
public string Description { get; private set; }
|
|
public Type EditorType { get; private set; }
|
|
public OverlayActionInfo(string description, Type editorType)
|
|
{
|
|
Description = description;
|
|
EditorType = editorType;
|
|
}
|
|
|
|
public OverlayActionInfo(string description)
|
|
{
|
|
Description = description;
|
|
EditorType = null;
|
|
}
|
|
|
|
public static IEnumerable<Type> GetTypesWithAttribute()
|
|
{
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
foreach (Type type in assembly.GetTypes())
|
|
{
|
|
if (type.GetCustomAttributes(typeof(OverlayActionInfo), true).Length > 0)
|
|
{
|
|
yield return type;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|