38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using Upsilon.BaseTypes.ScriptFunction;
|
|
using Upsilon.BaseTypes.UserData;
|
|
|
|
namespace Upsilon.StandardLibraries
|
|
{
|
|
internal abstract class ScriptLibrary
|
|
{
|
|
public Dictionary<string, LoadedStandardFunction> LoadMethods()
|
|
{
|
|
var dictionary = new Dictionary<string, LoadedStandardFunction>();
|
|
var methods = GetType().GetMethods();
|
|
foreach (var methodInfo in methods)
|
|
{
|
|
var attr = methodInfo.GetCustomAttribute<ScriptFunctionAttribute>();
|
|
if (attr != null)
|
|
{
|
|
dictionary.Add(attr.Name, new LoadedStandardFunction()
|
|
{
|
|
MethodInfoFunction = new ScriptMethodInfoFunction(new UserDataMethod(methodInfo),
|
|
this, true, attr.PassScriptReference, attr.PassScopeReference),
|
|
CommentValue = attr.Comment
|
|
});
|
|
}
|
|
}
|
|
|
|
return dictionary;
|
|
}
|
|
|
|
}
|
|
|
|
internal class LoadedStandardFunction
|
|
{
|
|
public ScriptMethodInfoFunction MethodInfoFunction { get; set; }
|
|
public string CommentValue { get; set; }
|
|
}
|
|
} |