Closed StuartFerguson closed 7 months ago
New Code
public static void LoadDomainEventsTypeDynamically(Assembly[] assemblies) { IEnumerable<Type> allTypes = assemblies.SelectMany(a => a.GetTypes()); List<Type> filteredTypes = allTypes .Where(t => t.IsSubclassOf(typeof(DomainEvent))) .OrderBy(e => e.Name).ToList(); foreach (Type type in filteredTypes) { TypeMap.AddType(type, type.Name); } }
Code example to call this
Assembly[] assemblies = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*DomainEvents*.dll") .Select(x => Assembly.Load(AssemblyName.GetAssemblyName(x))).ToArray(); LoadDomainEventsTypeDynamically(assemblies);
New Code
Code example to call this