Ejemplo n.º 1
0
 private static Dictionary <Tuple <Type, string>, Type> BuildCommandTypeIndex()
 {
     return(Discover.ConcreteTypesDerivedFrom(typeof(ICommand))
            .Select(commandType => new
     {
         commandType,
         targetType = commandType.GetInterface("ICommand`1")
                      .IfNotNull()
                      .Then(i => i.GetGenericArguments().Single())
                      .ElseDefault()
     })
            .ToDictionary(
                p => Tuple.Create(p.targetType, p.commandType.Name),
                p => p.commandType));
 }
Ejemplo n.º 2
0
        internal static Type[] ConcreteTypesOf(Type eventType)
        {
            var types = Discover.ConcreteTypesDerivedFrom(eventType);

            if (!typeof(IScheduledCommand).IsAssignableFrom(eventType))
            {
                return(types.ToArray());
            }

            if (eventType.IsGenericType)
            {
                var type = typeof(CommandScheduled <>).MakeGenericType(eventType.GetGenericArguments());
                return(types.Concat(new[] { type })
                       .Distinct()
                       .ToArray());
            }

            return(types.Concat(AggregateType.KnownTypes.Select(t => typeof(CommandScheduled <>).MakeGenericType(t)).ToArray())
                   .Distinct()
                   .ToArray());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns all known concrete event types.
 /// </summary>
 public static IEnumerable <Type> KnownTypes() => Discover.ConcreteTypesDerivedFrom(typeof(IEvent));