Wie scanne und konfiguriere ich Profile in AutoMapper automatisch?

Gibt es eine Möglichkeit, Automapper so zu konfigurieren, dass alle Profile im Namespace / in der Assembly gesucht werden? Ich möchte AutoMapper Zuordnungsprofile aus einer bestimmten Assembly hinzufügen, die nach einer bestimmten Schnittstelle gefiltert ist, wie etwa Scan-Konventionen in StructureMap:

    public static void Configure()
    {
        ObjectFactory.Initialize(x =>
            {
                // Scan Assembly
                x.Scan(
                    scanner =>
                    {
                        scanner.TheCallingAssembly();
                        scanner.Convention<MyCustomConvention>();
                        scanner.WithDefaultConventions();
                    });

                // Add Registries
                x.AddRegistry(new SomeRegistry());
            });

        Debug.WriteLine(ObjectFactory.WhatDoIHave());
    }

public class MyCustomConvention : IRegistrationConvention
{
    public void Process(Type type, Registry registry)
    {
        if (!type.CanBeCastTo(typeof(IMyType)))
        {
            return;
        }

        string name = type.Name.Replace("SomeRubishName", String.Empty);
        registry.AddType(typeof(IMyType), type, name);            
    }

Ich habe versucht, SelfConfigure zu verwenden, kann aber keine Dokumentation dazu finden, wie man damit Profile herausfiltert:

    public static void Configure()
    {
        Mapper.Initialize(x =>
                              {
                                  // My Custom profile
                                  x.AddProfile<MyMappingProfile>();

                                  // Scan Assembly
                                  x.SelfConfigure(Assembly.GetCallingAssembly());
                              });
    }

Eine andere Frage ist, wie ich alle bereits initialisierten Maps / Profile (so etwas wie ObjectFactory.WhatDoIHave () in StructureMap) melden kann.

Antworten auf die Frage(6)

Ihre Antwort auf die Frage