public void Start() { //启动服务器 server.Start(app => { //注册WebSocket连接 IDictionary <string, Type> webSocketConnectionDict = WebSocket.WebSocketManager.Instance.GetConnectionTypeDict(); if (webSocketConnectionDict.Count > 0) { var OwinExtensionType = typeof(OwinExtension); var MapWebSocketRouteMethod = OwinExtensionType.GetMethod(nameof(OwinExtension.MapWebSocketRoute), new Type[] { typeof(IAppBuilder), typeof(string), typeof(Microsoft.Practices.ServiceLocation.IServiceLocator) }); foreach (var item in webSocketConnectionDict) { var route = item.Key; var connectionType = item.Value; var method = MapWebSocketRouteMethod.MakeGenericMethod(connectionType); method.Invoke(null, new object[] { app, route, null }); } } //中间件上下文 app.Use <MiddlewareContext>(); //注册所有的中间件 foreach (var register in middlewareRegisterActionList) { register.Invoke(app); } }, endpoint); //初始化所有的中间件 this.Middlewares = MiddlewareContext.Instance.Middlewares; HunterUtils.TryHunt(this.Middlewares, properties); MiddlewareContext.Instance.IsReady = true; }
private void _Init(INode node, IDictionary <string, string> properties) { HunterUtils.TryHunt(node, properties); HunterUtils.TryHunt(node.GetMethods().Values, properties); foreach (var childNode in node.GetChildren()) { _Init(childNode, properties); } }
private void init(IDictionary <String, String> properties, IPEndPoint endpoint) { this.properties = properties; this.endpoint = endpoint; Server.Instance = this; HunterUtils.TryHunt(this, properties); server = (IWebServer)AssemblyUtils.CreateObject(Wrapper); HunterUtils.TryHunt(server, properties); }
public override void Register(OwinMiddleware item) { if (Server.Instance?.properties != null) { HunterUtils.TryHunt(item, Server.Instance.properties); } var preLastMiddleware = GetItems().LastOrDefault(); base.Register(item); if (preLastMiddleware != null) { preLastMiddleware.SetNext(item); } item.SetNext(TailMiddleware); }
protected override void OnStart(string[] args) { if (!ProgramUtils.IsMonoRuntime() && ProgramUtils.IsRuningOnWindows() && Environment.Version < Version.Parse("4.0.30319.17929")) { throw new ApplicationException("需要安装4.5或更新版本的Microsoft .NET Framework才能运行此程序!"); } if (Entrance.Parameter.OnServiceStarting != null) { Entrance.Parameter.OnServiceStarting.Invoke(); } if (Entrance.Parameter.LoadAllPlugins) { pluginActivators = AppDomain.CurrentDomain.GetAssemblies() .Select(ass => ass.GetTypes().FirstOrDefault(t => !t.IsAbstract && !t.IsNotPublic && t.IsClass && typeof(IPluginActivator).IsAssignableFrom(t) )).Where(t => t != null) .Select(t => (IPluginActivator)Activator.CreateInstance(t)).ToArray(); //启动所有插件 foreach (var activator in pluginActivators) { activator.Start(); } } //启动所有服务 foreach (var service in ServiceManager.Instance.GetItems()) { Console.Write($"服务[{service.Name}]"); HunterUtils.TryHunt(service, Entrance.Parameter.Properties); Console.Write($"->启动中"); service.Start(); Console.WriteLine($"->完成"); } if (Entrance.Parameter.OnServiceStarted != null) { Entrance.Parameter.OnServiceStarted.Invoke(); } }
public void Start() { //APP构造器 //var appBuilder = new AppBuilder(); //启动服务器 server.Start(app => { //中间件上下文 app.Use <MiddlewareContext>(); //注册所有的中间件 foreach (var register in middlewareRegisterActionList) { register.Invoke(app); } }, endpoint); //初始化所有的中间件 this.Middlewares = MiddlewareContext.Instance.Middlewares; HunterUtils.TryHunt(this.Middlewares, properties); MiddlewareContext.Instance.IsReady = true; }
public LoginController() { //Init properties HunterUtils.TryHunt(this, Program.GlobalProperties); }
internal void RegisterController(string plugin, string path, T controller) { controllerDict[$"{plugin}:{path}"] = controller; HunterUtils.TryHunt(controller, properties); }
private void RegisterController(string path, HttpController httpController) { HunterUtils.TryHunt(httpController, properties); routes.Add(RouteBuilder.RouteToRegex(path), httpController); }
public WinServiceInstaller() { //读取全部配置文件 HunterUtils.TryHunt(this, Entrance.Parameter.Properties); }