Exemplo n.º 1
0
        /// <summary>
        /// 注册给定程序集中的所有的AggregateRootEvent,扫描实现了IAggregateRootEvent接口的类
        /// </summary>
        private void RegisterAggregateRootEvents(params Assembly[] assemblies)
        {
            DependencyResolver.RegisterTypes(TypeUtils.IsAggregateRootEvent, assemblies);
            var provider = DependencyResolver.Resolve <IAggregateRootEventTypeProvider>();

            foreach (var assembly in assemblies)
            {
                foreach (var aggregateRootEventType in assembly.GetTypes().Where(x => TypeUtils.IsAggregateRootEvent(x)))
                {
                    provider.RegisterAggregateRootEventTypeMapping(TypeUtils.GetAggregateRootType(aggregateRootEventType), aggregateRootEventType);
                }
            }
        }