public void Use(Action <WebContext, MiddleWareBase> action) { if (_root == null) { _root = new MiddlewareNode(action); _curent = _root; } else { _curent._next = new MiddlewareNode(action); _curent = _curent._next; } }
public void UseMiddleWare <T>() { Type type = typeof(T); if (type.IsSubclassOf(typeof(MiddleWareBase))) { if (_root == null) { _root = (MiddleWareBase)Activator.CreateInstance(type); _curent = _root; } else { _curent._next = (MiddleWareBase)Activator.CreateInstance(type); _curent = _curent._next; } } else { throw new Exception("Class must inherit from MiddleWareBase"); } }