public void Stop() { var ctx = FeaturesBootstrapContext; OnStop(ctx); Deactivate(ctx); FeaturesBootstrapContext = null; }
public void Start(params object[] services) { var ctx = new FeaturesBootstrapContext(); ctx.Set(services); OnStart(ctx); Activate(ctx); FeaturesBootstrapContext = ctx; }
public override void Deactivate(FeaturesBootstrapContext ctx) { var dependencyResolver = Previous; if (dependencyResolver != null) { DependencyResolver.SetResolver(dependencyResolver); } }
public override void OnStart(FeaturesBootstrapContext ctx) { ctx.Pulse.On(FeaturesBootstrapState.RegisterServices, x => OnRegisterServices(x.Get<IServiceCollection>())); ctx.Pulse.On(FeaturesBootstrapState.RegisteredServices, x => OnRegisteredServices(x.Get<IServiceCollection>(), x)); ctx.Pulse.On(FeaturesBootstrapState.Started, OnStarted); ctx.Pulse.On(FeaturesBootstrapState.Stoped, OnStoped); ctx.Pulse.Catch(OnException); }
public override void Deactivate(FeaturesBootstrapContext ctx) { if (Previous != null) { var formatters = ctx.Get<HttpConfiguration>().Formatters; formatters.Clear(); formatters.AddRange(Previous); } }
public override void Deactivate(FeaturesBootstrapContext ctx) { var dependencyResolver = Previous; if (dependencyResolver != null) { var config = ctx.Get<HttpConfiguration>(); config.DependencyResolver = dependencyResolver; } }
public override void Activate(FeaturesBootstrapContext ctx) { var config = ctx.Get<HttpConfiguration>(); var swagger = config.EnableSwagger(ConfigureSwaggerDocs); if (UseSwaggerUi) { swagger.EnableSwaggerUi(); } }
public override void Activate(FeaturesBootstrapContext ctx) { if (UseGlobalConfiguration) { GlobalConfiguration.Configure(config => Activate(ctx, config)); } else { Activate(ctx, new HttpConfiguration()); } }
public override void Activate(FeaturesBootstrapContext ctx) { if (Bootstrapper.Kernel == null) { Bootstrapper.Initialize(CreateKernel); } if (ctx != null) { var kernel = Bootstrapper.Kernel; ctx.Set<IKernel>(kernel); ctx.Set<IServiceCollection>(new NInjectServiceCollection(kernel)); } }
protected void Deactivate(FeaturesBootstrapContext ctx) { var pulse = ctx.Pulse; try { pulse.OnNext(FeaturesBootstrapState.Stoping); pulse.OnNext(FeaturesBootstrapState.DeactivateFeatures); pulse.OnNext(FeaturesBootstrapState.DeactivatedFeatures); pulse.OnNext(FeaturesBootstrapState.Stoped); } catch (Exception ex) { Trace.TraceError(ex.Message); pulse.OnError(ex); } }
protected FeaturesBootstrapContext Activate(FeaturesBootstrapContext ctx) { var pulse = ctx.Pulse; try { Root.Init(ctx); pulse.OnNext(FeaturesBootstrapState.Starting); pulse.OnNext(FeaturesBootstrapState.ActivateFeatures); pulse.OnNext(FeaturesBootstrapState.ActivatedFeatures); pulse.OnNext(FeaturesBootstrapState.RegisterServices); pulse.OnNext(FeaturesBootstrapState.RegisteredServices); pulse.OnNext(FeaturesBootstrapState.RegisterMiddleware); pulse.OnNext(FeaturesBootstrapState.RegisteredMiddleware); pulse.OnNext(FeaturesBootstrapState.StartShell); pulse.OnNext(FeaturesBootstrapState.StartedShell); pulse.OnNext(FeaturesBootstrapState.Started); } catch (Exception ex) { Trace.TraceError(ex.Message); pulse.OnError(ex); } return ctx; }
public override void Activate(FeaturesBootstrapContext ctx) { var formatters = ctx.Get<HttpConfiguration>().Formatters; Previous = formatters.ToArray(); var json = formatters.JsonFormatter; var xml = formatters.XmlFormatter; formatters.Clear(); if (UseJson) { json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); json.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; json.SerializerSettings.Converters.Add(new StringEnumConverter()); formatters.Add(json); } if (UseXml) { xml.UseXmlSerializer = true; formatters.Add(xml); } }
public abstract void OnStop(FeaturesBootstrapContext ctx);
public override void Deactivate(FeaturesBootstrapContext ctx) { Bootstrapper.ShutDown(); }
public override void Deactivate(FeaturesBootstrapContext ctx) { }
private static void OnStoped(FeaturesBootstrapContext ctx) { Trace.WriteLine("Application is stoped."); }
public virtual void Init(FeaturesBootstrapContext ctx) { ctx.Pulse.On(FeaturesBootstrapState.ActivateFeatures, Activate); ctx.Pulse.On(FeaturesBootstrapState.DeactivateFeatures, Deactivate); }
public override void OnStop(FeaturesBootstrapContext ctx) { }
public override void Init(FeaturesBootstrapContext ctx) { base.Init(ctx); ctx.Pulse.On(FeaturesBootstrapState.RegisteredServices, RegisteredServices); }
public override void Activate(FeaturesBootstrapContext ctx) { AreaRegistration.RegisterAllAreas(ctx); }
private void OnRegisteredServices(FeaturesBootstrapContext ctx) { var config = ctx.Get<HttpConfiguration>(); var serviceProvider = ctx.Get<IServiceProvider>(); config.DependencyResolver = new WebApiDependencyResolver(serviceProvider, Previous); }
public override void Activate(FeaturesBootstrapContext ctx) { var config = ctx.Get<HttpConfiguration>(); Previous = config.DependencyResolver; }
private static void OnRegisteredServices(IServiceCollection services, FeaturesBootstrapContext ctx) { var serviceProvider = services.BuildServiceProvider(); ctx.Set(serviceProvider); }
private void Activate(FeaturesBootstrapContext ctx, HttpConfiguration config) { ctx.Set(config); base.Activate(ctx); }
private static void OnException(FeaturesBootstrapContext ctx, Exception exception) { Trace.TraceError("Application has failed: " + exception.Message); }
private static void RegisteredServices(FeaturesBootstrapContext ctx) { var app = ctx.Get<IAppBuilder>(); var configuration = ctx.Get<HttpConfiguration>(); app.UseWebApi(configuration); }
public abstract void Deactivate(FeaturesBootstrapContext ctx);
public override void Activate(FeaturesBootstrapContext ctx) { Deactivate(ctx); FilterAttributes.Add(new HandleErrorAttribute()); FilterAttributes.ForEach(GlobalFilters.Add); }
public override void Activate(FeaturesBootstrapContext ctx) { var config = ctx.Get<HttpConfiguration>(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); }
public override void Deactivate(FeaturesBootstrapContext ctx) { FilterAttributes.ForEach(GlobalFilters.Remove); FilterAttributes.Clear(); }