コード例 #1
0
        public static void ValidateRegistrations(
            this IResolver resolver)
        {
            var exceptions = new List <Exception>();

            foreach (var type in resolver.GetRegisteredServices().Where(t => !t.IsClosedTypeOf(typeof(IAggregateRoot <>))))
            {
                try
                {
                    resolver.Resolve(type);
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }

            if (!exceptions.Any())
            {
                return;
            }

            var message = string.Join(", ", exceptions.Select(e => e.Message));

            throw new AggregateException(message, exceptions);
        }