This documentation applies to Glass.Mapper.Sc 4.1+.

Using the Dependency Resolver it is possible add custom tasks and Data Mappers to Glass.Mapper.Sc.

The Dependency Resolver is created in the GlassMapperScCustom.CreateResolver() method:

public static IDependencyResolver CreateResolver()
{
    var config = new Config();
    var dependencyResolver = new DependencyResolver(config);
}

New tasks can be added to the Dependency Resolver by calling the Add/Delete/Insert methods of the relevant IConfigFactory. This can be accessed via the different properties on the Dependency Resolver, for example:

dependencyResolver. DataMapperFactory.Insert(0, ()=< new MyMapper());

The IConfigFactory exposes the following methods:

void Insert<TK>(int index, Func<TK> add) where TK : T;
Insert a construction method at the given location in the list of construction methods. We recommend that you use InsertBefore or InsertAfter instead of this method.
void Add<TK>(Func<TK> add) where TK : T;
Add a construction method to the end of the list of construction methods.
void First<TK>(Func<TK> add) where TK : T;
Insert aconstruction method as the first task/mapper to be run.
void Replace<TK>(int index, Func<TK> replace) where TK : T;
Replace a construction method with new construction method at the given location.
void Replace<TReplace, TK>(Func<TK> func) where TReplace : T where TK : T;
Replaces the construction method the returns the given type (TReplace) with the new construction method.
void InsertBefore<TBefore, TK>(Func<TK> func) where TBefore : T where TK : T;
Inserts a construction method before the method that returns the specified type (TBefore).
void InsertAfter<TAfter, TK>(Func<TK> func) where TAfter : T where TK : T;
Inserts a construction method after the method that returns the specified type (TBefore).

Upgrading

If you are upgrading from an earlier version of Glass.Mapper.Sc you will need to recompile all projects that reference the Glass.Mapper.Sc assemblies.