Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/17/12 21:46:00 (12 years ago)
Author:
jkarder
Message:

#1926:

  • added OpenArgument
  • refactored argument handling infrastructure
Location:
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/Arguments/HideStarterArgument.cs

    r8748 r8818  
    2020#endregion
    2121
     22using System;
     23
    2224namespace HeuristicLab.PluginInfrastructure {
     25  [Serializable]
    2326  public class HideStarterArgument : CommandLineArgument<bool> {
    2427    public const string TOKEN = "hideStarter";
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/Arguments/StartArgument.cs

    r8748 r8818  
    2020#endregion
    2121
     22using System;
     23
    2224namespace HeuristicLab.PluginInfrastructure {
     25  [Serializable]
    2326  public class StartArgument : CommandLineArgument<string> {
    2427    public const string TOKEN = "start";
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/CommandLineArgument.cs

    r8748 r8818  
    2020#endregion
    2121
     22using System;
     23
    2224namespace HeuristicLab.PluginInfrastructure {
     25  [Serializable]
    2326  public abstract class CommandLineArgument<T> : ICommandLineArgument<T> {
    2427    object ICommandLineArgument.Value { get { return Value; } }
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/CommandLineArgumentHandling.cs

    r8748 r8818  
    2222using System;
    2323using System.Collections.Generic;
     24using System.IO;
    2425using System.Linq;
    2526using System.Text.RegularExpressions;
     
    4344    private static ICommandLineArgument ParseArgument(string entry) {
    4445      var regex = new Regex(@"^/[A-Za-z]+(:[A-Za-z0-9\s]+)?$");
    45       if (!regex.IsMatch(entry)) return null;
    46       entry = entry.Remove(0, 1);
    47       var parts = entry.Split(':');
    48       string key = parts[0].Trim();
    49       string value = parts.Length == 2 ? parts[1].Trim() : string.Empty;
    50       switch (key) {
    51         case StartArgument.TOKEN: return new StartArgument(value);
    52         case HideStarterArgument.TOKEN: return new HideStarterArgument(value);
    53         default: return null;
    54       }
     46      bool isFile = File.Exists(entry);
     47      if (!regex.IsMatch(entry) && !isFile) return null;
     48      if (!isFile) {
     49        entry = entry.Remove(0, 1);
     50        var parts = entry.Split(':');
     51        string key = parts[0].Trim();
     52        string value = parts.Length == 2 ? parts[1].Trim() : string.Empty;
     53        switch (key) {
     54          case StartArgument.TOKEN: return new StartArgument(value);
     55          case HideStarterArgument.TOKEN: return new HideStarterArgument(value);
     56          default: return null;
     57        }
     58      } else return new OpenArgument(entry);
    5559    }
    5660  }
Note: See TracChangeset for help on using the changeset viewer.