public IDisposable Load() { var facility = new BottlesServicePackageFacility(); PackageRegistry.LoadPackages(x => x.Facility(facility)); PackageRegistry.AssertNoFailures(); _services = facility.Services(); if (!_services.Any()) { throw new ApplicationException("No services were detected. Shutting down."); } var tasks = _services.Select(x => x.ToTask()).ToArray(); _services.Each(x => EventAggregator.Messaging.AddListener(x)); tasks.Each(x => x.Start()); Task.WaitAll(tasks); return(this); }
public IDisposable Load() { var facility = new BottlesServicePackageFacility(); PackageRegistry.LoadPackages(x => x.Facility(facility)); PackageRegistry.AssertNoFailures(); _services = facility.Services(); if (!_services.Any()) { throw new ApplicationException("No services were detected. Shutting down."); } var tasks = _services.Select(x => x.ToTask()).ToArray(); _services.Each(x => EventAggregator.Messaging.AddListener(x)); tasks.Each(x => x.Start()); Task.WaitAll(tasks); return this; }
public BottleServiceRunner Bootstrap(string bootstrapperType = null) { if (bootstrapperType.IsNotEmpty()) { var type = Type.GetType(bootstrapperType); var bootstrapper = Activator.CreateInstance(type).As<IBootstrapper>(); var wrapped = new WrappedBootstrapper(bootstrapper); PackageRegistry.LoadPackages(x => x.Bootstrapper(wrapped)); PackageRegistry.AssertNoFailures(); return new BottleServiceRunner(wrapped.BottleServices()); } var facility = new BottlesServicePackageFacility(); PackageRegistry.LoadPackages(x => x.Facility(facility)); PackageRegistry.AssertNoFailures(); return facility.Aggregator.ServiceRunner(); }