public CollectionManager
     (TComponent parent,
     Action <TEntityBaseEventClass> raiseEventThroughParent,
     IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar)
     : base(parent, raiseEventThroughParent, appliersRegistrar)
 {
 }
예제 #2
0
파일: AkkaModule.cs 프로젝트: tuga1975/CQRS
        /// <summary>
        /// Loads the module into the kernel.
        /// </summary>
        public override void Load()
        {
            Bind <IAkkaAggregateRepository <TAuthenticationToken> >().To <AkkaAggregateRepository <TAuthenticationToken> >().InSingletonScope();
            Bind <IAkkaSagaRepository <TAuthenticationToken> >().To <AkkaSagaRepository <TAuthenticationToken> >().InSingletonScope();
            Bind <IAkkaEventPublisher <TAuthenticationToken> >().To <AkkaEventBus <TAuthenticationToken> >().InSingletonScope();
            Bind <IAkkaEventPublisherProxy <TAuthenticationToken> >().To <AkkaEventBusProxy <TAuthenticationToken> >().InSingletonScope();
            Bind <IAkkaCommandPublisher <TAuthenticationToken> >().To <AkkaCommandBus <TAuthenticationToken> >().InSingletonScope();
            Bind <IAkkaCommandPublisherProxy <TAuthenticationToken> >().To <AkkaCommandBusProxy <TAuthenticationToken> >().InSingletonScope();

            BusRegistrar.GetEventHandlerRegistrar = (messageType, handlerDelegateTargetedType) =>
            {
                bool isAnActor = messageType != null && messageType.GetNestedTypes().Any(type => type.Name == "Actor");
                IEventHandlerRegistrar eventHandlerRegistrar = null;
                if (isAnActor)
                {
                    eventHandlerRegistrar = Resolve <IAkkaEventPublisher <TAuthenticationToken> >() as IEventHandlerRegistrar;
                }
                return(eventHandlerRegistrar ?? Resolve <IEventHandlerRegistrar>());
            };

            BusRegistrar.GetCommandHandlerRegistrar = (messageType, handlerDelegateTargetedType) =>
            {
                bool isAnActor = handlerDelegateTargetedType != null && handlerDelegateTargetedType.GetProperty("AggregateResolver", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public) != null;
                ICommandHandlerRegistrar commandHandlerRegistrar = null;
                if (isAnActor)
                {
                    commandHandlerRegistrar = Resolve <IAkkaCommandPublisher <TAuthenticationToken> >() as ICommandHandlerRegistrar;
                }
                return(commandHandlerRegistrar ?? Resolve <ICommandHandlerRegistrar>());
            };
        }
예제 #3
0
 protected NestedComponent
     (IUtcTimeTimeSource timeSource,
     Action <TNestedComponentBaseEventClass> raiseEventThroughParent,
     IEventHandlerRegistrar <TNestedComponentBaseEventInterface> appliersRegistrar,
     bool registerEventAppliers) : base(timeSource, raiseEventThroughParent, appliersRegistrar, registerEventAppliers)
 {
 }
예제 #4
0
 protected EntityCollectionManagerBase
     (TParent parent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar)
 {
     ManagedEntities = new EntityCollection <TEntity, TEntityId>();
     _parent         = parent;
     appliersRegistrar
     .For <TEntityBaseEventInterface>(e => ManagedEntities[IdGetter.GetId(e)].ApplyEvent(e));
 }
 protected NestedEntity
     (IUtcTimeTimeSource timeSource,
     Action <TEntityBaseEventClass> raiseEventThroughParent,
     IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar)
     : base(timeSource, raiseEventThroughParent, appliersRegistrar, registerEventAppliers: false)
 {
     RegisterEventAppliers()
     .For <TEntityCreatedEventInterface>(e => Id = IdGetterSetter.GetId(e));
 }
예제 #6
0
 protected SlavedNestedEntity
     (IUtcTimeTimeSource timeSource,
     Action <TEntityBaseEventClass> raiseEventThroughParent,
     IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar)
     : base(timeSource, raiseEventThroughParent, appliersRegistrar, registerEventAppliers: false)
 {
     RegisterEventAppliers()
     .IgnoreUnhandled <TEntityBaseEventInterface>();
 }
예제 #7
0
 protected EntityCollectionManager
     (TParent parent,
     Action <TEntityBaseEventClass> raiseEventThroughParent,
     IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar)
     : base(parent, raiseEventThroughParent, appliersRegistrar)
 {
     appliersRegistrar.For <TEntityRemovedEventInterface>(
         e =>
     {
         var id = IdGetter.GetId(e);
         ManagedEntities.Remove(id);
     });
 }
 protected EntityCollectionManager
     (TParent parent,
     Action <TEntityBaseEventClass> raiseEventThroughParent,
     IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar)
 {
     ManagedEntities          = new EntityCollection <TEntity, TEntityId>();
     _raiseEventThroughParent = raiseEventThroughParent;
     _parent = parent;
     appliersRegistrar
     .For <TEntityCreatedEventInterface>(
         e =>
     {
         var entity = ObjectFactory <TEntity> .CreateInstance(_parent);
         ManagedEntities.Add(entity, IdGetter.GetId(e));
     })
     .For <TEntityBaseEventInterface>(e => ManagedEntities[IdGetter.GetId(e)].ApplyEvent(e));
 }
예제 #9
0
 public static IUpCastEventHandlerRegistrar <TNewBaseEvent> UpCast <TBaseEvent, TNewBaseEvent>(this IEventHandlerRegistrar <TBaseEvent> @this)
     where TBaseEvent : class
     where TNewBaseEvent : class, TBaseEvent
 {
     return(new UpCastEventHandlerRegistrar <TBaseEvent, TNewBaseEvent>(@this));
 }
예제 #10
0
 public GenericEventHandlerRegistrar(IEventHandlerRegistrar <TBaseEventInterface> innerRegistrar)
 {
     _innerRegistrar = innerRegistrar;
 }
예제 #11
0
 public static IGenericEventHandlerRegistrar MakeGeneric <TBaseEvent>(this IEventHandlerRegistrar <TBaseEvent> @this)
     where TBaseEvent : class
 {
     return(new GenericEventHandlerRegistrar <TBaseEvent>(@this));
 }
예제 #12
0
 public static IEventHandlerRegistrar <TNewBaseEvent> DownCast <TBaseEvent, TNewBaseEvent>(this IEventHandlerRegistrar <TBaseEvent> @this)
     where TBaseEvent : class
     where TNewBaseEvent : class, TBaseEvent
 {
     return(@this);
 }
예제 #13
0
 public static IEventHandlerRegistrar <TBaseEvent> AfterHandlers <TBaseEvent>
     (this IEventHandlerRegistrar <TBaseEvent> @this, Action <TBaseEvent> handler) where TBaseEvent : class
 {
     return(@this.AfterHandlers <TBaseEvent>(handler));
 }
예제 #14
0
 public UpCastEventHandlerRegistrar(IEventHandlerRegistrar <TBaseEvent> innerRegistrar)
 {
     _innerRegistrar = innerRegistrar;
 }
예제 #15
0
            internal Component(IUtcTimeTimeSource timeSource, Action <TComponentBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TComponentBaseEventInterface> appliersRegistrar, bool registerEventAppliers)
            {
                TimeSource = timeSource;
                _raiseEventThroughParent = raiseEventThroughParent;
                _eventHandlersEventDispatcher.Register()
                .IgnoreUnhandled <TComponentBaseEventInterface>();

                if (registerEventAppliers)
                {
                    appliersRegistrar
                    .For <TComponentBaseEventInterface>(ApplyEvent);
                }
            }