コード例 #1
0
 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));
 }
コード例 #5
0
 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);
                }
            }