<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentSecurity.Scanning.TypeScanners;

namespace FluentSecurity.Diagnostics
{
	public class SecurityEventListenerScanner : ITypeScanner
	{
		private readonly Func<Assembly, Type[]> _assemblyTypeProvider;
		private readonly bool _ignoreTypeLoadExceptions;

		public SecurityEventListenerScanner(bool ignoreTypeLoadExceptions) : this(ignoreTypeLoadExceptions, assembly => assembly.GetExportedTypes()) {}

		public SecurityEventListenerScanner(bool ignoreTypeLoadExceptions, Func<Assembly, Type[]> assemblyTypeProvider)
		{
			_assemblyTypeProvider = assemblyTypeProvider;
			_ignoreTypeLoadExceptions = ignoreTypeLoadExceptions;
		}

		public IEnumerable<Type> Scan(IEnumerable<Assembly> assemblies)
		{
			return assemblies.SelectMany(a =>
			{
				try
				{
					return _assemblyTypeProvider.Invoke(a);
				}
				catch (TypeLoadException exception)
				{
					Publish.ConfigurationEvent(() => exception.Message);

					if (!_ignoreTypeLoadExceptions)
						throw;

					return new Type[0];
				}
			}).Where(TypeIsExternalListener).ToList();
		}

		private static bool TypeIsExternalListener(Type type)
		{
			var interfaceType = typeof (ISecurityEventListener);
			return
				interfaceType.IsAssignableFrom(type) &&
				!type.IsInterface &&
				!type.Assembly.Equals(interfaceType.Assembly);
		}
	}
}<commit_msg>- Cleaned up implementation of SecurityEventListenerScanner.<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentSecurity.Scanning.TypeScanners;

namespace FluentSecurity.Diagnostics
{
	public class SecurityEventListenerScanner : ITypeScanner
	{
		private readonly Func<Assembly, Type[]> _assemblyTypeProvider;
		private readonly bool _ignoreTypeLoadExceptions;

		public SecurityEventListenerScanner(bool ignoreTypeLoadExceptions) : this(ignoreTypeLoadExceptions, assembly => assembly.GetExportedTypes()) {}

		public SecurityEventListenerScanner(bool ignoreTypeLoadExceptions, Func<Assembly, Type[]> assemblyTypeProvider)
		{
			_assemblyTypeProvider = assemblyTypeProvider;
			_ignoreTypeLoadExceptions = ignoreTypeLoadExceptions;
		}

		public IEnumerable<Type> Scan(IEnumerable<Assembly> assemblies)
		{
			return assemblies.SelectMany(GetTypesFromAssembly).Where(TypeIsExternalListener).ToList();
		}

		private IEnumerable<Type> GetTypesFromAssembly(Assembly assembly)
		{
			try
			{
				return _assemblyTypeProvider.Invoke(assembly);
			}
			catch (TypeLoadException exception)
			{
				Publish.ConfigurationEvent(() => exception.Message);

				if (!_ignoreTypeLoadExceptions)
					throw;

				return new Type[0];
			}
		}

		private static bool TypeIsExternalListener(Type type)
		{
			var interfaceType = typeof (ISecurityEventListener);
			return
				interfaceType.IsAssignableFrom(type) &&
				!type.IsInterface &&
				!type.Assembly.Equals(interfaceType.Assembly);
		}
	}
}
{'fraction_non_alphanumeric': 0.08596373404969779, 'fraction_numerical': 0.000671591672263264, 'mean_word_length': 5.298097251585624, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5709818', 'n_tokens_mistral': 964, 'n_tokens_neox': 806, 'n_words': 158}