Giter Club home page Giter Club logo

Comments (4)

Tyrrrz avatar Tyrrrz commented on September 18, 2024

Initial design:

Extend CommandOptionAttribute/CommandParameterAttribute with an additional property Type? ConverterType { get; set; }. The converter has to implement some IArgumentConverter.

Since an argument can be scalar and non-scalar, in order to support both, IArgumentConverter would need to either have two methods (for a list of arguments and for one argument) or have one just for a list and let the user deal with it (nasty). It also needs a property IsScalar which is important when binding parameters from multiple arguments because it needs to be known pretty early.

This overall sounds pretty meh because it exposes quite a few points of failure where the user may forget something or do something incorrectly.

from clifx.

Tyrrrz avatar Tyrrrz commented on September 18, 2024

Current workaround without implementing anything:

Assume we have type MyType and a function MyType Convert(string). We can simply define our option/parameter as a string or IEnumerable<string> and then do the conversion inside ExecuteAsync manually. Not too pretty but still reasonable.

from clifx.

oshustov avatar oshustov commented on September 18, 2024

Hey, @Tyrrrz ! I would like to have a look at this issue. I maybe have a solution which works with both MyCustomType and IEnumerable<MyCustomType> and other generic collections, but I am not sure that I clearly catched what did you mean at It also needs a property IsScalar which is important when binding parameters from multiple arguments because it needs to be known pretty early. As I see, non-scalar types use same scalar type converters for each argument in the list, aren`t they?

from clifx.

Tyrrrz avatar Tyrrrz commented on September 18, 2024

Hi @AlexandrShustov.

As I see, non-scalar types use same scalar type converters for each argument in the list, aren`t they?

They do. I think when I wrote this I was thinking of cases where the user may want to convert the entire list, not just item by item. You can ignore this for now and see maybe it's not necessary after all.

from clifx.

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.