static void Main(string[] args) { try { var chatServiceConfiguration = NinjectWcfConfiguration.Create <ChatService, NinjectServiceSelfHostFactory>(); using (var host = new NinjectSelfHostBootstrapper(CreateKernel, chatServiceConfiguration)) { host.Start(); Console.ReadKey(); } } catch (Exception exception) { Console.WriteLine(exception); } }
/// <summary> /// The application main method. /// </summary> /// <param name="args">The arguments.</param> public static void Main(string[] args) { var webApiConfiguration = new HttpSelfHostConfiguration("http://localhost:8080"); webApiConfiguration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{id}", defaults: new { id = RouteParameter.Optional, controller = "values" }); using (var selfHost = new NinjectSelfHostBootstrapper(CreateKernel, webApiConfiguration)) { selfHost.Start(); Console.WriteLine("Press Enter to quit."); Console.ReadLine(); } }
private static NinjectSelfHostBootstrapper CreateAndStartTestService(TestServiceConfiguration config, IKernel kernel) { var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None) { SendTimeout = TimeSpan.FromSeconds(10) }; var address = new Uri(BaseUrl, config.Id); var wcfConfig = NinjectWcfConfiguration.Create <DefaultTestService, NinjectServiceSelfHostFactory>( h => h.AddServiceEndpoint(typeof(ITestService), binding, address)); var host = new NinjectSelfHostBootstrapper(() => kernel, wcfConfig); if (!kernel.GetAll <INinjectSelfHost>().Any()) { throw new TestServiceException("Can't start test service because no instances of `INinjectSelfHost` are registered"); } host.Start(); return(host); }
public static void Main(string[] args) { // The hosting model can be explicitly configured with the SERVER_HOSTING_MODEL environment variable. // See https://www.andrecarlucci.com/en/setting-environment-variables-for-asp-net-core-when-publishing-on-iis/ for // setting the variable in IIS. var model = Environment.GetEnvironmentVariable("SERVER_HOSTING_MODEL"); // Command line arguments have higher precedence than environment variables model = args.FirstOrDefault(arg => arg.StartsWith("--use"))?.Substring(5) ?? model; var hostConfiguration = new AspNetCoreHostConfiguration(args) .UseStartup <Startup>() .UseWebHostBuilder(CreateWebHostBuilder) .BlockOnStart(); switch (model) { case "Kestrel": hostConfiguration.UseKestrel(); break; case "HttpSys": hostConfiguration.UseHttpSys(); break; case "IIS": case "IISExpress": hostConfiguration.UseIIS(); break; default: throw new ArgumentException($"Unknown hosting model '{model}'"); } var host = new NinjectSelfHostBootstrapper(CreateKernel, hostConfiguration); host.Start(); }
public static void Main(string[] args) { DbAutoMapper.Initialize(); var webApiConfiguration = new HttpSelfHostConfiguration("http://localhost:8080"); webApiConfiguration.MapHttpAttributeRoutes(); var cors = new EnableCorsAttribute("*", "*", "*"); webApiConfiguration.EnableCors(cors); webApiConfiguration.Formatters.JsonFormatter.MediaTypeMappings .Add(new System.Net.Http.Formatting.RequestHeaderMapping("Accept", "text/html", StringComparison.InvariantCultureIgnoreCase, true, "application/json")); using (var selfHost = new NinjectSelfHostBootstrapper(CreateKernel, webApiConfiguration)) { selfHost.Start(); Console.WriteLine("Press Enter to quit."); Console.ReadLine(); } Console.WriteLine("Buka"); }