begin code overhauls

This commit is contained in:
Zontreck 2020-03-10 11:47:20 -07:00
parent 9969e466d8
commit eb1026f8f4
14 changed files with 544 additions and 197 deletions

15
NonCommands/NotCommand.cs Normal file
View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Bot.NonCommands
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class NotCommand : Attribute
{
public NotCommand()
{
// Not Command, this just marks a class
}
}
}

14
NonCommands/nCMD.cs Normal file
View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
namespace Bot.NonCommands
{
public interface nCMD
{
public void handle(string text, UUID User, string agentName, MessageHandler.Destinations src, UUID originator);
}
}

41
NonCommands/nRegistry.cs Normal file
View file

@ -0,0 +1,41 @@
using OpenMetaverse;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Reflection;
namespace Bot.NonCommands
{
public class nRegistry
{
public static void Dispatch(string request, UUID agentKey, string agentName, MessageHandler.Destinations sourceLoc, UUID originator)
{
foreach(Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
foreach(Type t in a.GetTypes())
{
if (t.IsClass)
{
foreach (NotCommand NC in (NotCommand[])t.GetCustomAttributes(false))
{
MethodInfo mi = t.GetMethod("handle");
ThreadStart work = delegate
{
mi.Invoke(Activator.CreateInstance(mi.DeclaringType), new object[] { request, agentKey, agentName, sourceLoc, originator });
};
Thread T = new Thread(work);
// _mi.Invoke(Activator.CreateInstance(_mi.DeclaringType), new object[] { });
T.Start();
}
}
}
}
}
}
}