예제 #1
0
 public void Stop()
 {
     var ctx = FeaturesBootstrapContext;
     OnStop(ctx);
     Deactivate(ctx);
     FeaturesBootstrapContext = null;
 }
예제 #2
0
 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);
     }
 }
예제 #4
0
 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;
     }
 }
예제 #7
0
        public override void Activate(FeaturesBootstrapContext ctx)
        {
            var config = ctx.Get<HttpConfiguration>();

            var swagger = config.EnableSwagger(ConfigureSwaggerDocs);
            if (UseSwaggerUi)
            {
                swagger.EnableSwaggerUi();
            }
        }
예제 #8
0
 public override void Activate(FeaturesBootstrapContext ctx)
 {
     if (UseGlobalConfiguration)
     {
         GlobalConfiguration.Configure(config => Activate(ctx, config));
     }
     else
     {
         Activate(ctx, new HttpConfiguration());
     }
 }
예제 #9
0
 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));
     }
 }
예제 #10
0
 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);
     }
 }
예제 #11
0
 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);
            }
        }
예제 #13
0
 public abstract void OnStop(FeaturesBootstrapContext ctx);
예제 #14
0
 public override void Deactivate(FeaturesBootstrapContext ctx)
 {
     Bootstrapper.ShutDown();
 }
예제 #15
0
 public override void Deactivate(FeaturesBootstrapContext ctx)
 {
 }
예제 #16
0
 private static void OnStoped(FeaturesBootstrapContext ctx)
 {
     Trace.WriteLine("Application is stoped.");
 }
예제 #17
0
 public virtual void Init(FeaturesBootstrapContext ctx)
 {
     ctx.Pulse.On(FeaturesBootstrapState.ActivateFeatures, Activate);
     ctx.Pulse.On(FeaturesBootstrapState.DeactivateFeatures, Deactivate);
 }
예제 #18
0
 public override void OnStop(FeaturesBootstrapContext ctx)
 {
 }
예제 #19
0
 public override void Init(FeaturesBootstrapContext ctx)
 {
     base.Init(ctx);
     ctx.Pulse.On(FeaturesBootstrapState.RegisteredServices, RegisteredServices);
 }
예제 #20
0
 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;
 }
예제 #23
0
 private static void OnRegisteredServices(IServiceCollection services, FeaturesBootstrapContext ctx)
 {
     var serviceProvider = services.BuildServiceProvider();
     ctx.Set(serviceProvider);
 }
예제 #24
0
 private void Activate(FeaturesBootstrapContext ctx, HttpConfiguration config)
 {
     ctx.Set(config);
     base.Activate(ctx);
 }
예제 #25
0
 private static void OnException(FeaturesBootstrapContext ctx, Exception exception)
 {
     Trace.TraceError("Application has failed: " + exception.Message);
 }
예제 #26
0
 private static void RegisteredServices(FeaturesBootstrapContext ctx)
 {
     var app = ctx.Get<IAppBuilder>();
     var configuration = ctx.Get<HttpConfiguration>();
     app.UseWebApi(configuration);
 }
예제 #27
0
 public abstract void Deactivate(FeaturesBootstrapContext ctx);
 public override void Activate(FeaturesBootstrapContext ctx)
 {
     Deactivate(ctx);
     FilterAttributes.Add(new HandleErrorAttribute());
     FilterAttributes.ForEach(GlobalFilters.Add);
 }
예제 #29
0
 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();
 }