Link Search Menu Expand Document

ClassHandlerMapper


A class that is being used to map a class handler into a class. This class is used as an alternative to the ClassHandler attribute.

Please see the IClassHandlerMapper for more details about 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

Let us say you had implemented a Person handler like below.

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?

There are various ways of mapping a class handler into an entity model. You can use either do the following approach.

Via the ClassHandlerMapper class.

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

Or, via the FluentMapper class.

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

Or, via an explicit ClassHandler attribute.

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