//type must be child of ProcessManager<TState> public static IProcessDescriptor ScanByConvention(Type processManagerType) { var stateType = ExtractStateType(processManagerType); var descriptor = new ProcessDescriptor(stateType, processManagerType); var domainBindedEvents = processManagerType.GetProperties() .Where(p => p.PropertyType.IsConstructedGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(Event <>)); foreach (var prop in domainBindedEvents) { var domainEventType = prop.PropertyType.GetGenericArguments().First(); descriptor.AddAcceptedMessage(domainEventType); } return(descriptor); }
public static ProcessDescriptor <TProcess, TState> CreateDescriptor <TProcess, TState>() where TState : class, IProcessState where TProcess : Process <TState> { var descriptor = new ProcessDescriptor <TProcess, TState>(); var domainBindedEvents = typeof(TProcess).GetProperties() .Where(p => p.PropertyType.IsConstructedGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(Event <>)); foreach (var prop in domainBindedEvents) { var domainEventType = prop.PropertyType.GetGenericArguments() .First(); descriptor.AddAcceptedMessage(domainEventType); } return(descriptor); }