Exemple #1
0
 public void AddType(Type type)
 {
     if (TypeCatalog != null && TypeCatalog.Contains(type))
     {
         throw new ArgumentException("Container already contain this type");
     }
     TypeCatalog.Add(type);
 }
Exemple #2
0
        public Task RegisterAggregate(IAggregateCommandsHandlerDescriptor descriptor)
        {
            var aggregateHubType = typeof(AggregateHubActor <>).MakeGenericType(descriptor.AggregateType);
            var aggregateActor   = CreateDIActor(aggregateHubType, descriptor.AggregateType.BeautyName() + "_Hub");

            foreach (var aggregateCommandInfo in descriptor.RegisteredCommands)
            {
                _aggregatesCatalog.Add(aggregateCommandInfo, aggregateActor);
            }

            return(Task.CompletedTask);
        }
Exemple #3
0
        public void AddType(Type type, Type baseType)
        {
            bool isValid = false;

            if (type.GetInterfaces().Contains(baseType) || (type.BaseType == baseType && baseType.IsAbstract))
            {
                isValid = true;
            }
            if (isValid)
            {
                TypeCatalog.Add(baseType);
                derivedTypesCatalog.Add(type);
            }
        }
        public void CommandExecutor_does_not_support_command_inheritance()
        {
            var catalog = new TypeCatalog <IActorRef, object>();

            catalog.Add <InflateNewBallonCommand>(TestActor);

            var actor = Sys.ActorOf(Props.Create(() => new AggregatesPipeActor(catalog)));

            var msg = new MessageMetadataEnvelop <CreateCommand>(new CreateCommand(1, Guid.NewGuid().ToString()), MessageMetadata.Empty);

            actor.Tell(msg);

            ExpectNoMsg();
        }
        public void CommandExecutor_routes_command_by_its_type()
        {
            var catalog = new TypeCatalog <IActorRef, object>();

            catalog.Add <InflateNewBallonCommand>(TestActor);

            var actor = Sys.ActorOf(Props.Create(() => new AggregatesPipeActor(catalog)));

            var msg = new MessageMetadataEnvelop <ICommand>(new InflateNewBallonCommand(1, Guid.NewGuid().ToString()),
                                                            MessageMetadata.Empty);

            actor.Tell(msg);

            ExpectMsg <MessageMetadataEnvelop <ICommand> >();
        }