示例#1
0
        public bool Start(HostControl hostControl)
        {
            ResolverConfig.Configure();

            _HostAPi = _HostFactory.Create();

            return(true);
        }
示例#2
0
        public void Configuration(IAppBuilder app)
        {
            Dependencies.ForceCopyLocal();

            HttpConfiguration configHTTP = new HttpConfiguration();

            configHTTP.Services.Replace(typeof(IExceptionHandler), new ExceptionHandler());

            configHTTP.Formatters.Add(configHTTP.Formatters.JsonFormatter);
            configHTTP.Formatters.Remove(configHTTP.Formatters.XmlFormatter);
            configHTTP.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling  = DateTimeZoneHandling.Local;
            configHTTP.Formatters.JsonFormatter.SerializerSettings.TypeNameHandling      = TypeNameHandling.Objects;
            configHTTP.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            //TypeAdapterConfig.Configure();

            app.UseNinjectMiddleware(() => { return(ResolverConfig.Configure().Container as IKernel); });
            app.UseNinjectWebApi(configHTTP);

            //configHTTP.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //     routeTemplate: "api/{controller}",
            //      defaults: new { id = RouteParameter.Optional });
            configHTTP.Routes.MapHttpRoute("DefaultApi", "api/{controller}");

            app.UseErrorPage(new Microsoft.Owin.Diagnostics.ErrorPageOptions()
            {
                ShowCookies          = true,
                ShowEnvironment      = true,
                ShowExceptionDetails = true,
                ShowHeaders          = true,
                ShowQuery            = true,
                ShowSourceCode       = true
            });

            configHTTP.MapHttpAttributeRoutes();

            configHTTP.EnsureInitialized();
        }
示例#3
0
 public override void Load() =>
 ResolverConfig.Configure(Kernel);