You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB
C#

using Newtonsoft.Json.Linq;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace DSWeb.EventProcessor
{
public abstract class EventProcessor
{
public abstract void Process(JObject paraObj);
public abstract bool CanProcess(string type);
}
public static class EventProcessChain
{
public static void ProcessEvent(string type, JObject paraObj)
{
var types = Assembly.GetExecutingAssembly().GetTypes();
var aType = typeof(EventProcessor);
foreach (var tp in types)
{
if (tp.IsSubclassOf(aType))
{
var proc = Activator.CreateInstance(tp) as EventProcessor;
if (proc.CanProcess(type))
{
proc.Process(paraObj);
break;
}
}
}
}
}
}