IEnumerable <CommandExecDescriptor> Patterns(IEnumerable <Type> types) => from t in types where Attribute.IsDefined(t, typeof(CommandPatternAttribute)) && t.BaseType.IsGenericType && !t.IsAbstract let typeArgs = t.BaseType.GetGenericArguments() where typeArgs.Length >= 2 let specType = typeArgs[1] select new CommandExecDescriptor { PatternType = t, SpecType = specType, CommandName = CommandSpecDescriptor.FromSpecType(specType).CommandName };
public static IReadOnlyList <CommandExecDescriptor> DescribeExecutors(this Assembly a) { var q = from t in a.GetTypes() where Attribute.IsDefined(t, typeof(CommandPatternAttribute)) && t.BaseType.IsGenericType && !t.IsAbstract let typeArgs = t.BaseType.GetGenericArguments() where typeArgs.Length >= 2 let specType = typeArgs[1] select new CommandExecDescriptor { PatternType = t, SpecType = specType, CommandName = CommandSpecDescriptor.FromSpecType(specType).CommandName }; return(q.ToList()); }
static CommandName GetCommandName <TSpec>() where TSpec : CommandSpec <TSpec>, new() => CommandSpecDescriptor.FromSpecType <TSpec>().CommandName;
static IAppMessage OrchestrationStartError(Type SpecType, Exception e) => AppMessage.Error("@CommandName orchestration start error: @ErrorDetail", new { CommandName = CommandSpecDescriptor.FromSpecType(SpecType).CommandName, ErrorDetail = e.ToString() });