Exemplo n.º 1
0
        public static ClientCofiguration AddType(this ClientCofiguration config, Type type)
        {
            foreach (var @interface in type.GetInterfaces())
            {
                if ([email protected])
                {
                    continue;
                }

                var genericDefinition = @interface.GetGenericTypeDefinition();

                if (genericDefinition == typeof(IReadModel <,>))
                {
                    AddReadModel(config, type, @interface);
                    continue;
                }

                if (genericDefinition != typeof(ICancellableCommandHandler <>) && genericDefinition != typeof(ICancellableEventHandler <>) &&
                    genericDefinition != typeof(ICommandHandler <>) && genericDefinition != typeof(IEventHandler <>) &&
                    genericDefinition != typeof(ISpecificationCommandHandler <>))
                {
                    continue;
                }

                var name = @interface.GetGenericArguments()[0].Name;

                config.RegisterHandler(name, type);
            }

            return(config);
        }
Exemplo n.º 2
0
 public static void AddReadModel(ClientCofiguration configuration, Type readModel, Type @interface)
 => configuration.RegisterHandler(@interface.GetGenericArguments()[0].FullName, readModel);