Skip to content

Add ITypeParser interface #50

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

Closed
akamsteeg opened this issue Sep 7, 2018 · 0 comments
Closed

Add ITypeParser interface #50

akamsteeg opened this issue Sep 7, 2018 · 0 comments
Assignees
Milestone

Comments

@akamsteeg
Copy link
Owner

akamsteeg commented Sep 7, 2018

In v2.0.0 we introduced the ICommandLineArgumentsParser (#8) and IHelpWriter (#11) interfaces but for a TypeParser there's no interface. For consistency, we should add a 'ITypeParser` interface too, so users don't need get confused about sometimes having to extend an abstract class and sometimes implement an interface.

Proposal:

public interface ITypeParser
{
    /// <summary>
    /// Gets the <see cref="Type"/> this <see cref="TypeParser{T}"/> handles
    /// </summary>
    Type Type { get; }

    /// <summary>
    /// Tries to parse the specified value to the specified parse result
    /// </summary>
    /// <param name="value">
    /// The value to parse
    /// </param>
    /// <param name="parseResult">
    /// The parsed value
    /// </param>
    /// <returns>
    /// True if value was converted successfully; otherwise, false
    /// </returns>
    bool TryParse(string value, out object parseResult);
}

We must also update the configuration and all usages to support the interface instead of the current abstract base class TypeParser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant