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; } } } } } }