private static IStoreEvents InitializeEventSourcing()
 {
     var dispatcher = new NServiceBusCommitDispatcher();
     var eventStore = new PersistenceWireup(
         Wireup.Init()
             .UsingInMemoryPersistence()
             .UsingSynchronousDispatchScheduler(dispatcher)
             )
         .InitializeStorageEngine()
         .Build();
     return eventStore;
 }
 private IStoreEvents InitializeEventSourcing()
 {
     var dispatcher = new NServiceBusCommitDispatcher();
     var eventStore = new PersistenceWireup(
         Wireup.Init()
             .UsingRavenPersistence("SecurityEventStore")
             .UsingAsynchronousDispatchScheduler(dispatcher)
             )
         .InitializeStorageEngine()
         .Build();
     return eventStore;
 }
示例#3
0
        public ViewBuilder()
        {
            _logger = log4net.LogManager.GetLogger(this.GetType());

            Type genericMessageHandlerType = typeof (IHandleMessages<>);
            var eventStore = new PersistenceWireup(
                Wireup.Init()
                    .UsingRavenPersistence("MembershipEventStore")
                )
                .InitializeStorageEngine()
                .Build();

            var container = BootstrapMessageHandlers();

            var commits = eventStore.Advanced.GetFrom(new DateTime(1900, 1, 1));
            foreach (var commit in commits)
            {
                foreach (var @event in commit.Events.Select(x => x.Body))
                {
                    Type eventType = @event.GetType();
                    _logger.InfoFormat("Handling event '{0}'", @eventType.Name);
                    Type specificEventHandlerType = genericMessageHandlerType.MakeGenericType(eventType);
                    Type enumerableOfEventHandlerType = typeof (IEnumerable<>).MakeGenericType(specificEventHandlerType);
                    var handlers = container.Resolve(enumerableOfEventHandlerType) as IEnumerable;
                    bool hadHandlers = false;
                    if (handlers != null)
                    {
                        foreach (var handler in handlers)
                        {
                            hadHandlers = true;
                            _logger.InfoFormat("  Processing event with handler {0}", handler.GetType());
                            var genericHandleMethod =
                                handler.GetType().GetMethods().Where(
                                    m => m.Name == "Handle" && m.GetParameters()[0].ParameterType == eventType).
                                    SingleOrDefault();
                            if (genericHandleMethod != null)
                            {
                                genericHandleMethod.Invoke(handler, new object[]{ @event });
                            }
                        }
                    }
                    if (!hadHandlers)
                    {
                        _logger.InfoFormat("No handlers found for event type {0}", eventType.Name);
                    }
                }
            }
        }
示例#4
0
 public static SerializationWireup UsingServiceStackJsonSerialization(this PersistenceWireup wireup)
 {
     return(wireup.UsingCustomSerialization(new ServiceStackJsonSerializer()));
 }
 public static SerializationWireup UsingBinarySerialization(this PersistenceWireup wireup)
 {
     return(wireup.UsingCustomSerialization(new BinarySerializer()));
 }
 public static SerializationWireup UsingCustomSerialization(this PersistenceWireup wireup, ISerialize serializer)
 {
     return(new SerializationWireup(wireup, serializer));
 }