Esempio n. 1
0
        public static void AddAutomationEventHandler(AutomationEvent eventId, AutomationElement element, TreeScope scope, AutomationEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationFocusChangedEvent, "Use FocusChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.StructureChangedEvent, "Use StructureChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationPropertyChangedEvent, "Use PropertyChange notification instead");

            try
            {
                BasicEventListener listener = new BasicEventListener(eventId, element, eventHandler);
                Factory.AddAutomationEventHandler(
                    eventId.Id,
                    element.NativeElement,
                    (UIAutomationClient.TreeScope)scope,
                    CacheRequest.CurrentNativeCacheRequest,
                    listener);
                ClientEventList.Add(listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
        }
Esempio n. 2
0
        public static void RemoveAutomationEventHandler(AutomationEvent eventId, AutomationElement element, AutomationEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationFocusChangedEvent, "Use FocusChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.StructureChangedEvent, "Use StructureChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationPropertyChangedEvent, "Use PropertyChange notification instead");

            try
            {
                BasicEventListener listener = (BasicEventListener)ClientEventList.Remove(eventId, element, eventHandler);
                Factory.RemoveAutomationEventHandler(eventId.Id, element.NativeElement, listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
        }
        public async Task ShouldSuccesfullyPersistAndHydrateEventsFromAggregate()
        {
            // ARRANGE
            var testAggregate = new TestAggregate(Guid.NewGuid());

            //var eventRepository = new SqlServerEventRepository("Server=tcp:shuffle.database.windows.net,1433;Initial Catalog=Shuffle;Persist Security Info=False;User ID=kvinther;Password=k1617v_KV;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Application Name=Shuffle;");
            var eventRepository  = new SqlServerEventRepository("Server=.\\sqlexpress;Initial Catalog=VerdunEvents;Persist Security Info=False;Trusted_Connection=True;MultipleActiveResultSets=False;Connection Timeout=30;Application Name=Shuffle;");
            var aggregateFactory = new DefaultAggregateFactory();
            var repository       = new AggregateRepository(eventRepository, aggregateFactory);
            var listener         = new BasicEventListener();

            IAggregateCache cache = null;

            //cache = new RedisAggregateCache("shuffle.redis.cache.windows.net:6380,password=z0cYd5K7aNjtE9tl8x6nxYa2lK5TwrJcB1aHsZGCx5Q=,ssl=True,abortConnect=False");
            cache = new RedisAggregateCache("localhost");
            var store = new AggregateStore(repository, listener, aggregateCache: cache);

            // ACT
            var now = DateTime.Now;

            for (var i = 1; i <= 50; i++)
            {
                testAggregate.PublishTestEvent($"{i}");
                await store.Save(testAggregate);

                var hydratedTestAggregate = store.GetById <TestAggregate>(testAggregate.Id);
                // ASSERT
                Assert.AreEqual(testAggregate.Id, hydratedTestAggregate.Id);
                Assert.AreEqual(testAggregate.Version, hydratedTestAggregate.Version);
                Assert.AreEqual(testAggregate.State, hydratedTestAggregate.State);
            }


            Debug.WriteLine($"Total time: {(DateTime.Now - now):g}");
        }
Esempio n. 4
0
        public void Initialize()
        {
            // Configuration Parameters
            var eventDatabaseConnectionString = "Data Source=localhost;Initial Catalog=eventway-sample-db;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            var projectionMetadataDatabaseConnectionString = eventDatabaseConnectionString;

            var cosmosDbEndpoint     = "https://localhost:8081"; // This is the default endpoint for local emulator-instances of the Cosmos DB
            var cosmosDbAuthKey      = "<REPLACE WITH YOUR COSMOS DB AUTH KEY>";
            var cosmosDbDatabaseId   = "eventway-sample-db";
            var cosmosDbCollectionId = "projections";
            var offerThroughput      = 10000;
            var noOfPartitions       = 1000;

            // Event Repository
            var eventRepository = new SqlServerEventRepository(eventDatabaseConnectionString);

            // Projection Metadata Repository
            var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(projectionMetadataDatabaseConnectionString);

            // Query Model Repository
            var queryModelRepository = new DocumentDbQueryModelRepository(cosmosDbDatabaseId, cosmosDbCollectionId,
                                                                          offerThroughput, noOfPartitions, cosmosDbEndpoint, cosmosDbAuthKey);

            queryModelRepository.Initialize();

            // Event Listener
            var eventListener = new BasicEventListener();

            // Aggregate services
            var aggregateFactory    = new DefaultAggregateFactory();
            var aggregateRepository = new AggregateRepository(eventRepository, aggregateFactory);
            var aggregateStore      = new AggregateStore(aggregateRepository, eventListener);

            // PROJECTIONS
            UserProjection = new UserProjection(
                eventRepository,
                eventListener,
                queryModelRepository,
                projectionMetadataRepository);

            // APPLICATION SERVICES
            UserApplicationService = new UserApplicationService(
                aggregateStore,
                queryModelRepository);

            // Start listening for events
            UserProjection.Listen();
        }
Esempio n. 5
0
        public void Initialize()
        {
            // Configuration Parameters
            var eventDatabaseConnectionString = "Data Source=localhost;Initial Catalog=eventway;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            var projectionMetadataDatabaseConnectionString = eventDatabaseConnectionString;

            var cosmosDbEndpoint     = "https://localhost:8081"; // This is the default endpoint for local emulator-instances of the Cosmos DB
            var cosmosDbAuthKey      = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
            var cosmosDbDatabaseId   = "eventway";
            var cosmosDbCollectionId = "projections";
            var offerThroughput      = 10000;
            var noOfPartitions       = 1000;

            // Event Repository
            var eventRepository = new SqlServerEventRepository(eventDatabaseConnectionString);

            // Projection Metadata Repository
            var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(projectionMetadataDatabaseConnectionString);

            // Query Model Repository
            var queryModelRepository = new CosmosDbQueryModelRepository(cosmosDbDatabaseId, cosmosDbCollectionId,
                                                                        offerThroughput, noOfPartitions, cosmosDbEndpoint, cosmosDbAuthKey);

            queryModelRepository.Initialize();

            // Event Listener
            var eventListener = new BasicEventListener();

            // Aggregate services
            var aggregateFactory    = new DefaultAggregateFactory();
            var aggregateRepository = new AggregateRepository(eventRepository, aggregateFactory);
            var aggregateStore      = new AggregateStore(aggregateRepository, eventListener);

            // PROJECTIONS
            UserProjection = new UserProjection(
                eventRepository,
                eventListener,
                queryModelRepository,
                projectionMetadataRepository);

            // APPLICATION SERVICES
            UserApplicationService = new UserApplicationService(
                aggregateStore,
                queryModelRepository);

            // Start listening for events
            UserProjection.Listen();
        }