Giter Club home page Giter Club logo

Users are forced to implement an interface to define composition handlers and are constrained to create multiple classes instead of defining multiple methods in the same composition handler class about servicecomposer.aspnetcore HOT 5 OPEN

servicecomposer avatar servicecomposer commented on August 25, 2024
Users are forced to implement an interface to define composition handlers and are constrained to create multiple classes instead of defining multiple methods in the same composition handler class

from servicecomposer.aspnetcore.

Comments (5)

mauroservienti avatar mauroservienti commented on August 25, 2024 1

Will an interface still be an option too do you think?

Not necessarily. I was thinking about keeping the current design and adding the new option.

In the convention case, when defining the method, does the "correct argument" imply a convention also? Just curious how to introduce model bound parameters to a method.

The thing I was brainstorming goes something like this:

  • when scanning assemblies scan for all types in a specific namespace (say for example *.Handlers)
  • look for all the public methods that returns Task and are decorated with one of the routing attributes (e.g. HttpGet)
  • for each them and compile an expression tree for each one to invoke them using a so called fast delegate approach
  • as we're doing today build the endpoint using the template defined in attribute, by storing in the custom endpoint also the list of parameters (using something like a parameter descriptor)

At invocation time:

  • bind the parameters stored in the endpoint
    • throw of some titles badly
  • use the compiled expression tree to invoke the user defined method passing the arguments returned by the bind operation

from servicecomposer.aspnetcore.

markphillips100 avatar markphillips100 commented on August 25, 2024 1

I like it @mauroservienti . So in theory you could get as near to controller action parameter behaviour. For example, not limit a method to just a model object but actual individual parameters with their own model binding attributes:

[HttpPost("cart/{orderId:guid}")]
Task PlaceOrder(HttpRequest httpRequest, [FromRoute] Guid orderId, [FromBody] PlaceOrderCommand command)

I think MVC defaults to FromBody semantics if you only specify a single object parameter and requires an explicit attribute if you include other parameters with attributes.

Always happy to help out if you need anything.

from servicecomposer.aspnetcore.

markphillips100 avatar markphillips100 commented on August 25, 2024

Will an interface still be an option too do you think?

In the convention case, when defining the method, does the "correct argument" imply a convention also? Just curious how to introduce model bound parameters to a method.

from servicecomposer.aspnetcore.

mauroservienti avatar mauroservienti commented on August 25, 2024

So in theory you could get as near to controller action parameter behaviour.

Correct, that's the idea

I think MVC defaults to FromBody semantics if you only specify a single object parameter and requires an explicit attribute if you include other parameters with attributes.

That's tricky; for example, take a look at this Stack Overflow discussion.

from servicecomposer.aspnetcore.

markphillips100 avatar markphillips100 commented on August 25, 2024

Ah right, so the optional FromBody only applies when using ApiController attributes on controllers. Good catch.

from servicecomposer.aspnetcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.