2018-11-21 19:59:27 +00:00
|
|
|
using System;
|
2019-01-18 15:09:25 +00:00
|
|
|
using System.Reflection;
|
2018-11-21 19:59:27 +00:00
|
|
|
|
|
|
|
namespace Upsilon.StandardLibraries
|
|
|
|
{
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
2019-02-16 12:30:22 +00:00
|
|
|
[JetBrains.Annotations.MeansImplicitUse]
|
2018-12-07 15:11:52 +00:00
|
|
|
public class ScriptFunctionAttribute : Attribute
|
2018-11-21 19:59:27 +00:00
|
|
|
{
|
2018-12-07 15:11:52 +00:00
|
|
|
public ScriptFunctionAttribute(string name, string comment = null,
|
2019-01-18 15:09:25 +00:00
|
|
|
bool directScriptManipulation = false, bool passScriptReference = false, bool passScopeReference = false,
|
|
|
|
Type overrideReturnType = null, string overrideReturnMethod = null)
|
2018-11-21 19:59:27 +00:00
|
|
|
{
|
|
|
|
Name = name;
|
2018-11-30 11:07:18 +00:00
|
|
|
Comment = comment;
|
2018-12-07 15:11:52 +00:00
|
|
|
DirectScriptManipulation = directScriptManipulation;
|
2018-11-30 10:31:45 +00:00
|
|
|
PassScriptReference = passScriptReference;
|
2018-12-03 17:32:27 +00:00
|
|
|
PassScopeReference = passScopeReference;
|
2019-01-18 15:09:25 +00:00
|
|
|
if (overrideReturnType != null && overrideReturnMethod != null)
|
|
|
|
{
|
|
|
|
var method = overrideReturnType.GetMethod(overrideReturnMethod,
|
|
|
|
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
|
|
|
|
OverrideReturnType = method;
|
|
|
|
}
|
2018-11-21 19:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public string Name { get; }
|
2018-11-30 11:07:18 +00:00
|
|
|
public string Comment { get; }
|
2018-12-07 15:11:52 +00:00
|
|
|
public bool DirectScriptManipulation { get; }
|
2018-11-30 10:31:45 +00:00
|
|
|
public bool PassScriptReference { get; }
|
2018-12-03 17:32:27 +00:00
|
|
|
public bool PassScopeReference { get; }
|
2019-01-18 15:09:25 +00:00
|
|
|
public MethodInfo OverrideReturnType { get; }
|
2018-11-21 19:59:27 +00:00
|
|
|
}
|
|
|
|
}
|