Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 870519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:29:26+00:00 2026-05-15T10:29:26+00:00

Library at http://testapi.codeplex.com/ Excerpt of usage from http://blogs.msdn.com/ivo_manolov/archive/2008/12/17/9230331.aspx A third common approach is forming

  • 0

Library at

http://testapi.codeplex.com/

Excerpt of usage from

http://blogs.msdn.com/ivo_manolov/archive/2008/12/17/9230331.aspx

A third common approach is forming strongly-typed commands from the command-line parameters. This is common for cases when the command-line looks as follows:

some-exe  COMMAND  parameters-to-the-command

The parsing in this case is a little bit more involved:

  1. Create one class for every supported command, which derives from the Command abstract base class and implements an expected Execute method.
  2. Pass an expected command along with the command-line arguments to CommandLineParser.ParseCommand – the method will return a strongly-typed Command instance that can be Execute()-d.

    // EXAMPLE #3: // Sample for parsing the following command-line:
    // Test.exe run /runId=10 /verbose
    // In this particular case we have an actual command on the command-line (“run”), which we want to effectively de-serialize and execute.

     public class   RunCommand : Command
     { 
     bool?  Verbose { get; set; } 
     int? RunId { get; set; }
     public override void Execute()
        {
       // Implement your "run" execution logic here.
        }
     }
      Command c = new RunCommand();
      CommandLineParser.ParseArguments(c, args);
      c.Execute();
    

============================

I don’t get if we instantiate specific class before parsing arguments , what’s the point of command line argument “run” which is very first one. I thought the idea was to instantiate and execute command/class based on a command line parameter ( “run” parameter becomes instance RunCommand class, “walk” becomes WalkCommand class and so on ). Can it be done with the latest version ? Moreover what I downloaded from codeplex doesn’t work the way described above and doesn’t accept the very first parameter without slash. So if using reflection I have to pass command name as usual parameter and do then multi-step – determining class name , instantiate via reflection, and only then parse other arguments via ParseArguments.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:29:26+00:00Added an answer on May 15, 2026 at 10:29 am

    MicMit,
    The example on my blog was actually flawed. I have since corrected it.

    In essence, what you do is:
    1. parse the 1st argument (the command name) to figure out what command you need to instantiate
    2. instantiate the target command, then pass the rest of the argument list to it.
    3. execute the command

    i.e. in your Main, you would do something like the following…

    if (String.Compare(args[0], "run", StringComparison.InvariantCultureIgnoreCase) == 0)
    {
        Command c = new RunCommand();
        c.ParseArguments(args.Skip(1)); // or CommandLineParser.ParseArguments(c, args.Skip(1))
        c.Execute();
    }
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does the latest version of the enterprise library ( http://msdn.microsoft.com/en-us/library/cc512464.aspx ) come with the
Using the DotNetZip Library (http://dotnetzip.codeplex.com/) is there a way to move files from one
I am using the control library from http://code.google.com/p/gong-wpf-dragdrop/successfully for my listbox dragging operation.But there
I published a simple ASP.net website referring to this link : http://msdn.microsoft.com/en-us/library/1y1404zt%28v=vs.80%29.aspx I managed
Naudio Library: http://naudio.codeplex.com/ I'm trying to convert an MP3 file to a WAV file,
I recently started using AutoFixture library (http://autofixture.codeplex.com/) for Unit Testing and I quite like
I came across this .NET library: http://www.webzinc.com/online/faq.aspx However, I was wondering if there was
I'm using the RazorEngine library ( http://razorengine.codeplex.com/ ) in an MVC 3 web application
I am using this library http://www.codeproject.com/KB/cs/tsnewlib.aspx to try and schedule tasks for Windows 7.
Ok guys, I am using the following library: http://www.codeproject.com/KB/recipes/AdvancedMatrixLibrary.aspx And I wish to calculate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.