Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #1
eglauko opened this issue May 30, 2022 · 0 comments
Open
Tracked by #1

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

eglauko opened this issue May 30, 2022 · 0 comments
Assignees
Labels
New New item to work Task A task to work
Milestone

Comments

@eglauko
Copy link
Member

eglauko commented May 30, 2022

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();
@eglauko eglauko mentioned this issue May 30, 2022
6 tasks
@eglauko eglauko self-assigned this May 30, 2022
@eglauko eglauko added this to the preview 1 milestone May 30, 2022
@eglauko eglauko added New New item to work Task A task to work labels May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New New item to work Task A task to work
Projects
None yet
Development

No branches or pull requests

1 participant