I am currently creating a few templates for my team to use within various projects.
I have a very simple "simple mapper" template and a wizard to go along with it that I'd like to expand adding others as I continue.
namespace $rootnamespace$;
public class $safeitemname$
{
public $mapto$ Map($mapfrom$ entity)
{
return new $mapto$()
{
Id = entity.Id,
Name = entity.Name
};
}
public $mapfrom$ MapToDb($mapto$ item)
{
return new $mapfrom$()
{
Id = item.Id,
Name = item.Name
};
}
}
$mapto$ is replaced with the user's input.
I would like to know if it's possible to look through the hosts solution, get the properties of a class referenced there (e.g. $mapto$
) and use this to default the mapping. Is this possible with item templates?
I have seen some reference to T4 templates and will be looking in to those, but would like to know if it's possible with the basic item templates.