Skip to content

Resolução do mapeamento de métodos. #5

Open
@eglauko

Description

@eglauko

Há dois tipos de mapeamento:

  • SourceToMethod
  • PropertyToMethod

Ao acionar no builder um ToMethod, deverá gerar ou obter uma ToMethodOptions existente.
Então os métodos ToMethod podem ter seletores, como o Delegate ou o nome + nº parametros ou tipos dos parâmetros.

Deve ser possível tratar o retorno do método, com uma função.

Deve-se poder criar tratamentos genéricos para retornos de função, pelo tipo retornado.
Quando não há nenhum tratamento para o retorno da função, o retorno é ignorado.
O tratamento deve retornar (void) (Action)

samples:

// maps the properties of the source type to the target method with name X.
builder.ToMethod("X");

// maps all source available properties to a target method.
builder.ToMethod();

// maps the given parameters to an unknown target method.
builder.ToMethod().Parameters(x => x.Name, x => x.Age);

// maps the properties of the source type to the target method with name X,
// where the two parameters of source type must be parameters of X.
// In this case, X method can have more parameters, but these two must be resolved.
builder.ToMethod("X")
    .Map(x => x.Name)
    .Map(x => x.Age);

// maps the source property to a target method, 
// where the inner properties will be mapped as parameters of the target method.
// In this case, the target type must hava a method with the property name, 
// and parameters with same names of the inner properties.
builder.Map(x => x.Something).ToMethod();

// maps the source property as a parameter (not defined) of a target method (not defined).
// In this case, the target type must have a single method with a single parameter of same type of the property type.
builder.Map(x => x.Name).ToMethod().ToParameter();

// maps multiples source properties to a method (Update) of a target property (SomeProp).
builder.Map(x => x.Name).To(t => t.SomeProp).ToMethod(p => p.Update).ToParameter();
builder.Map(x => x.Age).To(t => t.SomeProp).ToMethod(p => p.Update).ToParameter();

Metadata

Metadata

Assignees

Labels

NewNew item to workTaskA task to work

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions