/// <summary>
        /// Starts the web API.
        /// </summary>
        /// <param name="factory">The factory to use.</param>
        /// <param name="options">The options to use.</param>
        public void StartWebApi(WebApiServerFactory factory, WebApiOptions options)
        {
            Log.Info("Starting web API server...");
            var config = new HttpSelfHostConfiguration(options.BaseEndpoint);

            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            json.SerializerSettings.Converters.Add(new StringEnumConverter());
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.Routes.MapHttpRoute("Project", "api/{controller}/{project}/{action}/{id}", new { action = "index", id = RouteParameter.Optional }, new { controller = "build|project" });
            config.Routes.MapHttpRoute("Default", "api/{controller}/{action}/{id}", new { action = "index", id = RouteParameter.Optional });
            config.DependencyResolver = new ScopeContainer(factory);
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            this.apiServer = new HttpSelfHostServer(config);
            apiServer.OpenAsync().Wait();
            Log.Info("...web API server started ({0})", options.BaseEndpoint);
        }
        /// <summary>
        /// Starts the web API.
        /// </summary>
        /// <param name="factory">The factory to use.</param>
        /// <param name="options">The options to use.</param>
        public void StartWebApi(WebApiServerFactory factory, WebApiOptions options)
        {
            Log.Info("Starting web API server...");
            var config = new HttpSelfHostConfiguration(options.BaseEndpoint);

            var json = config.Formatters.JsonFormatter;

            json.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            json.SerializerSettings.Converters.Add(new StringEnumConverter());
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.Routes.MapHttpRoute("Project", "api/{controller}/{project}/{action}/{id}", new { action = "index", id = RouteParameter.Optional }, new { controller = "build|project" });
            config.Routes.MapHttpRoute("Default", "api/{controller}/{action}/{id}", new { action = "index", id = RouteParameter.Optional });
            config.DependencyResolver = new ScopeContainer(factory);
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            this.apiServer = new HttpSelfHostServer(config);
            apiServer.OpenAsync().Wait();
            Log.Info("...web API server started ({0})", options.BaseEndpoint);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ScopeContainer"/> class.
 /// </summary>
 /// <param name="factory">The factory with the server scope.</param>
 public ScopeContainer(WebApiServerFactory factory)
 {
     this.factory = factory;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ScopeContainer"/> class.
 /// </summary>
 /// <param name="factory">The factory with the server scope.</param>
 public ScopeContainer(WebApiServerFactory factory)
 {
     this.factory = factory;
 }