예제 #1
0
        public void GetControllerNameTest()
        {
            Assert.AreEqual("FileUrl", RpcRoot.GetControllerName <IFileUrlController>());
            string typeName = typeof(ICaptchaController <string>).Name;

            Console.WriteLine(typeName);
            Assert.AreEqual("Captcha", RpcRoot.GetControllerName <ICaptchaController <string> >());
        }
예제 #2
0
        public void TaskTest()
        {
            HttpClient client = RpcRoot.CreateHttpClient();

            client.GetAsync($"http://{RpcRoot.OfficialServerAddress}/api/{RpcRoot.GetControllerName<IAppSettingController>()}/{nameof(IAppSettingController.GetTime)}")
            .ContinueWith(t => {
                Console.WriteLine(t.Result.Content.ReadAsAsync <DateTime>().Result);
            }).Wait();
        }
예제 #3
0
 private static void Run()
 {
     try {
         string baseAddress = $"http://{NTKeyword.Localhost}:{ServerRoot.HostConfig.GetServerPort().ToString()}";
         HttpServer.Start(baseAddress, doConfig: config => {
             // 向后兼容
             config.Routes.MapHttpRoute("CalcConfigs", "api/ControlCenter/CalcConfigs", new {
                 controller = RpcRoot.GetControllerName <ICalcConfigController>(),
                 action     = nameof(ICalcConfigController.CalcConfigs)
             });
         });
         Windows.ConsoleHandler.Register(Close);
         WaitHandle.WaitOne();
         Close();
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     finally {
         Close();
     }
 }