예제 #1
0
        //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);
        }
예제 #2
0
        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);
        }