public static IServiceCollection AddDataChangedEvents(this IServiceCollection serviceCollection,
                                                              params Assembly[] assemblies)
        {
            var scanner = new DataChangedEventScanner();

            scanner.ScanAssemblies(assemblies);
            var repository = new DataChangedEventRepository(scanner.Added, scanner.Updated, scanner.Removed);

            return(serviceCollection.AddSingleton <IDataChangedEventRepository>(repository));
        }
Exemple #2
0
        public void Fill_the_store()
        {
            var scanner = new DataChangedEventScanner();

            scanner.ScanAssemblies(GetType().Assembly);


            scanner.Added.ContainsKey(typeof(Data1)).Should().BeTrue();
            scanner.Updated.ContainsKey(typeof(Data1)).Should().BeTrue();
            scanner.Removed.ContainsKey(typeof(Data1)).Should().BeTrue();
            scanner.Removed.ContainsKey(typeof(Data2)).Should().BeTrue();

            scanner.Added.TryGetValue(typeof(Data1), out var at1);
            scanner.Updated.TryGetValue(typeof(Data1), out var ut1);
            scanner.Removed.TryGetValue(typeof(Data1), out var rt1);
            scanner.Removed.TryGetValue(typeof(Data2), out var rt2);

            at1.Should().Be(typeof(Data1Added));
            ut1.Should().Be(typeof(Data1Updated));
            rt1.Should().Be(typeof(Data1Removed));
            rt2.Should().Be(typeof(Data2Removed));
        }