Directory Mapper

Mappings are stored by this class. It is a property on LDAP Configuration and some of it's functionality is exposed on that class, but it can be shared among multiple configurations. It uses a concurrent dictionary internally.

IDrectoryMapper mapper = new DirectoryMapper();

mapper.Map(new AutoClassMap<User>(), "naming context");
mapper.Map(new AttributeClassMap<Role>());
mapper.Map(new ServerMap(), "override mapped naming context");
mapper.Map(new EmailServerMap());
mapper.Map(new WebServerMap());
mapper.AddMappingsFrom("OtherMappings.dll");
    
Auto Mapping
Querying for an unmapped class (with attributes or without) will cause it to be auto mapped. This is done with AutoClassMap or AttributeClassMap. You can optionally specify how auto mapping will be done (using your own implementations of AutoClassMap or AttributeClassMap).

var mapper = new DirectoryMapper();

mapper.AutoMapWith(type =>
{
    var mapType = typeof(AutoClassMap<>).MakeGenericType(type);

    return (IClassMap)Activator.CreateInstance(mapType);
});

mapper.AttributeMapWith(type =>
{
    var mapType = typeof(AttributeClassMap<>).MakeGenericType(type);

    return (IClassMap)Activator.CreateInstance(mapType);
});

Last edited Jun 12, 2012 at 3:35 AM by MadHatter22, version 3