protected virtual IEnumerable <DiscoveredModel> DiscoverCustomLogic(DiscoveryContext context) { yield return(new DiscoveredModel(typeof(IMigrationCustomLogic), typeof(NoCustomLogic), ServiceLifetime.Transient) { CanOverrideDefaults = true }); }
protected override IEnumerable <DiscoveredModel> GetModels(DiscoveryContext context) { var models = base.GetModels(context).ToList(); models.Add(new DiscoveredModel(typeof(Projections.Versioning.ProjectionHasher), typeof(Projections.Versioning.ProjectionHasher), ServiceLifetime.Singleton)); return(models); }
protected virtual IEnumerable <DiscoveredModel> DiscoverCronusStartups(DiscoveryContext context) { foreach (var startupType in context.Assemblies.Find <ICronusStartup>()) { yield return(new DiscoveredModel(startupType, startupType, ServiceLifetime.Singleton)); } yield return(new DiscoveredModel(typeof(Cronus.ProjectionsStartup), typeof(Cronus.ProjectionsStartup), ServiceLifetime.Transient)); // TODO: Check if this is alrady registered in the foreach above. If yes we can remove this line. Elase we have to figure out what is going on }
public IDiscoveryResult <TCronusService> Discover() { DiscoveryContext context = new DiscoveryContext(); context.Configuration = Configuration; context.Assemblies = AssemblyLoader.Assemblies.Values; var discoveryResult = DiscoverFromAssemblies(context); return(discoveryResult); }
protected override DiscoveryResult <IEventStore> DiscoverFromAssemblies(DiscoveryContext context) { IEnumerable <DiscoveredModel> models = DiscoverIndices(context) .Concat(new[] { new DiscoveredModel(typeof(IEventStoreInterceptor), typeof(NoAggregateCommitTransformer), ServiceLifetime.Singleton), new DiscoveredModel(typeof(NoAggregateCommitTransformer), typeof(NoAggregateCommitTransformer), ServiceLifetime.Singleton), new DiscoveredModel(typeof(EventStoreFactory), typeof(EventStoreFactory), ServiceLifetime.Scoped) }); return(new DiscoveryResult <IEventStore>(models)); }
protected override DiscoveryResult <ICronusHost> DiscoverFromAssemblies(DiscoveryContext context) { IEnumerable <DiscoveredModel> models = DiscoverCronusHost(context) .Concat(DiscoverCronusStartups(context)) .Concat(DiscoverCommands(context)) .Concat(DiscoverEvents(context)) .Concat(DiscoverPublicEvents(context)) .Concat(DiscoverSignals(context)) .Concat(DiscoverMigrations(context)); return(new DiscoveryResult <ICronusHost>(models)); }
protected virtual IEnumerable <DiscoveredModel> GetModels(DiscoveryContext context) { var foundTypes = context.FindService <T>(); foreach (var type in foundTypes) { yield return(new DiscoveredModel(type, type, ServiceLifetime.Transient)); } yield return(new DiscoveredModel(typeof(TypeContainer <T>), new TypeContainer <T>(foundTypes))); yield return(new DiscoveredModel(typeof(IHandlerFactory), provider => new DefaultHandlerFactory(type => provider.GetRequiredService(type)), ServiceLifetime.Transient)); }
protected virtual IEnumerable <DiscoveredModel> GetModels(DiscoveryContext context) { var loadedTypes = context.Assemblies.SelectMany(asm => asm.GetLoadableTypes()) .Where(type => type.IsAbstract == false && type.IsInterface == false && typeof(T).IsAssignableFrom(type)); foreach (var type in loadedTypes) { yield return(new DiscoveredModel(type, type, ServiceLifetime.Transient)); } yield return(new DiscoveredModel(typeof(TypeContainer <T>), new TypeContainer <T>(loadedTypes))); yield return(new DiscoveredModel(typeof(IHandlerFactory), provider => new DefaultHandlerFactory(type => provider.GetRequiredService(type)), ServiceLifetime.Transient)); }
public IEnumerable <IDiscoveryResult <object> > Scan(DiscoveryContext context) { var discoveries = context.Assemblies .SelectMany(asm => asm .GetLoadableTypes() .Where(type => type.IsAbstract == false && type.IsClass && typeof(IDiscovery <object>).IsAssignableFrom(type))) .Select(dt => (IDiscovery <object>)FastActivator.CreateInstance(dt)); foreach (var discovery in discoveries) { logger.Info(() => $"Discovered {discovery.Name}"); yield return(discovery.Discover(context)); } }
IEnumerable <DiscoveredModel> GetModels(DiscoveryContext context) { foreach (var startupType in context.Assemblies.Find <ICronusStartup>()) { yield return(new DiscoveredModel(startupType, startupType, ServiceLifetime.Singleton)); } yield return(new DiscoveredModel(typeof(ICronusHost), typeof(CronusHost), ServiceLifetime.Transient)); yield return(new DiscoveredModel(typeof(Cronus.ProjectionsBooter), typeof(Cronus.ProjectionsBooter), ServiceLifetime.Transient)); yield return(new DiscoveredModel(typeof(BoundedContext), typeof(BoundedContext), ServiceLifetime.Transient)); var loadedTypes = context.Assemblies.Find <IEvent>().Where(type => type != typeof(EntityEvent)); yield return(new DiscoveredModel(typeof(TypeContainer <IEvent>), new TypeContainer <IEvent>(loadedTypes))); }
protected virtual IEnumerable <DiscoveredModel> DiscoverAggregateRepository(DiscoveryContext context) { yield return(new DiscoveredModel(typeof(AggregateRepository), typeof(AggregateRepository), ServiceLifetime.Transient)); if ("true".Equals(context.Configuration["Cronus:PublishAggregateCommits"], System.StringComparison.OrdinalIgnoreCase)) { yield return(new DiscoveredModel(typeof(AggregateCommitPublisherRepository), provider => new AggregateCommitPublisherRepository(provider.GetRequiredService <AggregateRepository>(), provider.GetRequiredService <IPublisher <AggregateCommit> >(), provider.GetRequiredService <CronusContext>(), provider.GetService <ILogger <AggregateCommitPublisherRepository> >()), ServiceLifetime.Transient)); yield return(new DiscoveredModel(typeof(CronusAggregateRepository), provider => new CronusAggregateRepository(provider.GetRequiredService <AggregateCommitPublisherRepository>(), provider.GetRequiredService <IPublisher <IEvent> >(), provider.GetRequiredService <IPublisher <IPublicEvent> >(), provider.GetRequiredService <CronusContext>()), ServiceLifetime.Transient)); } else { yield return(new DiscoveredModel(typeof(CronusAggregateRepository), provider => new CronusAggregateRepository(provider.GetRequiredService <AggregateRepository>(), provider.GetRequiredService <IPublisher <IEvent> >(), provider.GetRequiredService <IPublisher <IPublicEvent> >(), provider.GetRequiredService <CronusContext>()), ServiceLifetime.Transient)); } yield return(new DiscoveredModel(typeof(LoggingAggregateRepository), provider => new LoggingAggregateRepository(provider.GetRequiredService <CronusAggregateRepository>(), provider.GetService <ILogger <LoggingAggregateRepository> >()), ServiceLifetime.Transient)); yield return(new DiscoveredModel(typeof(IAggregateRepository), provider => provider.GetRequiredService <LoggingAggregateRepository>(), ServiceLifetime.Transient)); }
public IEnumerable <IDiscoveryResult <object> > Scan(DiscoveryContext context) { List <Type> allTypes = context.Assemblies .SelectMany(asm => asm .GetLoadableTypes() .Where(type => type.IsAbstract == false && type.IsClass && typeof(IDiscovery <object>).IsAssignableFrom(type))) .ToList(); IEnumerable <IDiscovery <object> > discoveries = allTypes .Where(candidate => allTypes.Where(t => t.BaseType == candidate).Any() == false) // filter out discoveries which inherit from each other. We remove the base discoveries .Select(dt => (IDiscovery <object>)FastActivator.CreateInstance(dt)); foreach (var discovery in discoveries) { logger.Info(() => $"Discovered {discovery.Name}"); yield return(discovery.Discover(context)); } }
protected virtual IEnumerable <DiscoveredModel> DiscoverIndices(DiscoveryContext context) { var appIndices = context.Assemblies.Find <IEventStoreIndex>(); yield return(new DiscoveredModel(typeof(TypeContainer <IEventStoreIndex>), new TypeContainer <IEventStoreIndex>(appIndices))); foreach (var indexDef in appIndices) { yield return(new DiscoveredModel(indexDef, indexDef, ServiceLifetime.Scoped)); } var systemIndices = context.Assemblies.Find <ICronusEventStoreIndex>(); yield return(new DiscoveredModel(typeof(TypeContainer <ICronusEventStoreIndex>), new TypeContainer <ICronusEventStoreIndex>(systemIndices))); foreach (var indexDef in systemIndices) { yield return(new DiscoveredModel(indexDef, indexDef, ServiceLifetime.Scoped)); } }
protected override DiscoveryResult <DiscoveryScanner> DiscoverFromAssemblies(DiscoveryContext context) { var discoveries = context.Assemblies .SelectMany(asm => asm .GetLoadableTypes() .Where(type => type.IsAbstract == false && type.IsClass && typeof(IDiscovery <object>).IsAssignableFrom(type) && type != typeof(DiscoveryScanner))) .Select(dt => (IDiscovery <object>)FastActivator.CreateInstance(dt)); foreach (var discovery in discoveries) { log.Info($"Discovered {discovery.Name}"); discovery.AssignPropertySafely <IHaveConfiguration>(x => x.Configuration = context.Configuration); var discoveryResult = discovery.Discover(); cronusServicesProvider.HandleDiscoveredModel(discoveryResult); } return(new DiscoveryResult <DiscoveryScanner>()); }
protected virtual IEnumerable <DiscoveredModel> DiscoverMigrations(DiscoveryContext context) { IEnumerable <Type> loadedMigrations = context.Assemblies.Find <IMigration>(); foreach (var migrationType in loadedMigrations) { var directInterfaces = GetDirectInterfaces(migrationType); foreach (var interfaceBase in directInterfaces) { var generics = interfaceBase.GetGenericArguments(); if (generics.Length == 1 && typeof(IMigration).IsAssignableFrom(interfaceBase)) { var tenantResolverType = typeof(IMigration <>); var tenantResolverTypeGeneric = tenantResolverType.MakeGenericType(generics.Single()); yield return(new DiscoveredModel(tenantResolverTypeGeneric, migrationType, ServiceLifetime.Transient) { CanAddMultiple = true }); } } }
protected virtual IEnumerable <DiscoveredModel> DiscoverWorkflows(DiscoveryContext context) { return(DiscoverModel <Workflow <HandleContext>, MessageHandleWorkflow>(ServiceLifetime.Transient)); }
protected override DiscoveryResult <IWorkflow> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <IWorkflow>(DiscoverWorkflows(context), RegisterGG)); }
protected override DiscoveryResult <MigrationDiscovery> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <MigrationDiscovery>(GetModels(context))); }
IEnumerable <DiscoveredModel> GetModels(DiscoveryContext context) { yield return(new DiscoveredModel(typeof(CopyEventStore <,>), typeof(CopyEventStore <,>), ServiceLifetime.Transient)); }
protected override DiscoveryResult <IWorkflow> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <IWorkflow>(GetModels())); }
protected override DiscoveryResult <ProjectionPlayer> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <ProjectionPlayer>(GetModels())); }
protected override DiscoveryResult <IAggregateRepository> DiscoverFromAssemblies(DiscoveryContext context) { IEnumerable <DiscoveredModel> models = DiscoverEventStreamIntegrityPolicy <EventStreamIntegrityPolicy>(context) .Concat(DiscoverAggregateRepository(context)); return(new DiscoveryResult <IAggregateRepository>(models)); }
protected override DiscoveryResult <ITenantList> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <ITenantList>(GetModels())); }
protected override DiscoveryResult <IPublisher <IMessage> > DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <IPublisher <IMessage> >(GetModels())); }
protected virtual IEnumerable <DiscoveredModel> DiscoverEventStreamIntegrityPolicy <TIntegrityPolicy>(DiscoveryContext context) where TIntegrityPolicy : IIntegrityPolicy <EventStream> { return(DiscoverModel <IIntegrityPolicy <EventStream>, TIntegrityPolicy>(ServiceLifetime.Transient)); }
protected override DiscoveryResult <IEventStore> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <IEventStore>(GetModels(context))); }
protected override DiscoveryResult <ICronusHost> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <ICronusHost>(GetModels(context))); }
public IDiscoveryResult <TCronusService> Discover(DiscoveryContext context) { return(DiscoverFromAssemblies(context)); }
protected abstract DiscoveryResult <TCronusService> DiscoverFromAssemblies(DiscoveryContext context);
protected override DiscoveryResult <IAggregateRepository> DiscoverFromAssemblies(DiscoveryContext context) { return(new DiscoveryResult <IAggregateRepository>(GetModels())); }