mirror of
https://github.com/opensim/opensim.git
synced 2026-07-05 11:37:48 +08:00
Implementing ability to register script constants and invocations on a region module automatically
This commit is contained in:
@@ -211,6 +211,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
||||
RegisterScriptInvocation(target, mi);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterScriptInvocations(IRegionModuleBase target)
|
||||
{
|
||||
foreach(MethodInfo method in target.GetType().GetMethods(
|
||||
BindingFlags.Public | BindingFlags.Instance |
|
||||
BindingFlags.Static))
|
||||
{
|
||||
if(method.GetCustomAttributes(
|
||||
typeof(ScriptInvocationAttribute), true).Any())
|
||||
{
|
||||
if(method.IsStatic)
|
||||
RegisterScriptInvocation(target.GetType(), method);
|
||||
else
|
||||
RegisterScriptInvocation(target, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Delegate[] GetScriptInvocationList()
|
||||
{
|
||||
@@ -313,6 +330,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterConstants(IRegionModuleBase target)
|
||||
{
|
||||
foreach (FieldInfo field in target.GetType().GetFields(
|
||||
BindingFlags.Public | BindingFlags.Static |
|
||||
BindingFlags.Instance))
|
||||
{
|
||||
if (field.GetCustomAttributes(
|
||||
typeof(ScriptConstantAttribute), true).Any())
|
||||
{
|
||||
RegisterConstant(field.Name, field.GetValue(target));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation to check for a registered constant
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user