コード例 #1
0
        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));
        }
コード例 #2
0
        public void GetFilteredTypes()
        {
            var types = new[]
            {
                typeof(Data1),
                typeof(Data1Added),
                typeof(Data1Updated),
                typeof(Data1Removed)
            };

            var scanner = new DataChangedEventScanner();

            scanner.IsDataChangedEventType(typeof(IDataRemovedEvent <Data1>)).Should().BeFalse();
            scanner.IsDataChangedEventType(typeof(Data1)).Should().BeFalse();
            scanner.IsDataChangedEventType(typeof(Data1Added)).Should().BeTrue();
            scanner.IsDataChangedEventType(typeof(Data1Updated)).Should().BeTrue();
            scanner.IsDataChangedEventType(typeof(Data1Updated)).Should().BeTrue();
        }
コード例 #3
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));
        }
コード例 #4
0
        public void GetDataType()
        {
            var scanner = new DataChangedEventScanner();

            scanner.GetDataType(typeof(Data1Added)).Should().Be(typeof(Data1));
        }