Link Search Menu Expand Document

ClassHandlerMapper


A mapper class for associating a class handler with a target class. This is the programmatic alternative to the ClassHandler attribute.

See IClassHandlerMapper for details on the property handling implementation.

Methods

Below is the list of methods.

NameDescription
AddAdds a class handler mapping on a specific class.
ClearClears all the existing property handler mappings.
GetGets the existing mapped class handler object on the class.
RemoveRemoves the existing mapped class handler of the class.

Usability

Given a Person class handler implementation:

public class PersonClassHandler : IClassHandler<Person>
{
    public Person Get(Person entity, ClassHandlerGetOptions options)
    {
        return entity;
    }

    public Person Set(Person entity, ClassHandlerSetOptions options)
    {
        return entity;
    }
}

How to Map?

A class handler can be mapped to an entity model using any of the following approaches.

Via ClassHandlerMapper:

PropertyHandlerMapper
    .Add(typeof(Person), new PersonClassHandler(), true);

Via FluentMapper:

FluentMapper
    .Entity<Person>()
    .ClassHandler<PersonClassHandler>();

Via the ClassHandler attribute:

[ClassHandler(typeof(PersonClassHandler))]
publi class Person
{
    ...
}