Example #1
0
        /// <summary>
        /// 初始化配置
        /// </summary>
        static void Init()
        {
            HttpServer.Start(9999);

            // 注册与配置IUserApi接口
            HttpApiFactory.Add <IUserApi>().ConfigureHttpApiConfig(c =>
            {
                c.HttpHost      = new Uri("http://localhost:9999/");
                c.LoggerFactory = new LoggerFactory().AddConsole();
                c.FormatOptions.DateTimeFormat = DateTimeFormats.ISO8601_WithMillisecond;
            });
        }
Example #2
0
        public void AddCreateTest()
        {
            HttpApiFactory.Add <IMyApi>()
            .SetLifetime(TimeSpan.FromMilliseconds(100d));

            var api1 = HttpApiFactory.Create <IMyApi>();
            var api2 = HttpApiFactory.Create <IMyApi>();

            Assert.True(IsHttpHandlerEquals(api1, api2));
            Assert.False(api1 == api2);

            Thread.Sleep(TimeSpan.FromMilliseconds(150));

            var api3 = HttpApiFactory.Create <IMyApi>();

            Assert.False(IsHttpHandlerEquals(api1, api3));
        }
Example #3
0
 public Startup(IConfiguration configuration)
 {
     // 注册与配置IUserApi接口
     HttpApiFactory.Add <IUserAPI>().ConfigureHttpApiConfig(c =>
     {
         c.HttpHost      = new Uri("http://localhost:55418/");
         c.LoggerFactory = new LoggerFactory().AddConsole();
         c.FormatOptions.DateTimeFormat = DateTimeFormats.ISO8601_WithMillisecond;
     });
     // 注册与配置IUserApi接口
     HttpApiFactory.Add <IOnlineStudyAPI>().ConfigureHttpApiConfig(c =>
     {
         c.HttpHost      = new Uri("http://localhost:50323/");
         c.LoggerFactory = new LoggerFactory().AddConsole();
         c.FormatOptions.DateTimeFormat = DateTimeFormats.ISO8601_WithMillisecond;
     });
     Configuration = configuration;
 }
        public void AddCreateTest()
        {
            HttpApiFactory.Add <IMyApi>()
            .SetLifetime(TimeSpan.FromMilliseconds(100d));

            var api1 = HttpApiFactory.Create <IMyApi>();
            var api2 = HttpApiFactory.Create <IMyApi>();

            Assert.True(IsHttpApiConfigEquals(api1, api2));
            Assert.False(api1 == api2);

            Thread.Sleep(TimeSpan.FromMilliseconds(150));

            var api3 = HttpApiFactory.Create <IMyApi>();

            Assert.False(IsHttpApiConfigEquals(api1, api3));

            api3.Dispose();
            Assert.True(GetHttpApiConfig(api3).IsDisposed == false);
        }
Example #5
0
 /// <summary>
 /// Http通知通道
 /// </summary>
 static HttpNotifyClient()
 {
     HttpApiFactory.Add <IHttpNotifyApi>();
 }