34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
using System;
|
|
using System.Reflection;
|
|
|
|
namespace Upsilon.StandardLibraries
|
|
{
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
|
[JetBrains.Annotations.MeansImplicitUse]
|
|
public class ScriptFunctionAttribute : Attribute
|
|
{
|
|
public ScriptFunctionAttribute(string name, string comment = null,
|
|
bool directScriptManipulation = false, bool passScriptReference = false, bool passScopeReference = false,
|
|
Type overrideReturnType = null, string overrideReturnMethod = null)
|
|
{
|
|
Name = name;
|
|
Comment = comment;
|
|
DirectScriptManipulation = directScriptManipulation;
|
|
PassScriptReference = passScriptReference;
|
|
PassScopeReference = passScopeReference;
|
|
if (overrideReturnType != null && overrideReturnMethod != null)
|
|
{
|
|
var method = overrideReturnType.GetMethod(overrideReturnMethod,
|
|
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
|
|
OverrideReturnType = method;
|
|
}
|
|
}
|
|
|
|
public string Name { get; }
|
|
public string Comment { get; }
|
|
public bool DirectScriptManipulation { get; }
|
|
public bool PassScriptReference { get; }
|
|
public bool PassScopeReference { get; }
|
|
public MethodInfo OverrideReturnType { get; }
|
|
}
|
|
} |