- Timestamp:
- 10/17/12 21:46:00 (12 years ago)
- 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 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.PluginInfrastructure { 25 [Serializable] 23 26 public class HideStarterArgument : CommandLineArgument<bool> { 24 27 public const string TOKEN = "hideStarter"; -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/Arguments/StartArgument.cs
r8748 r8818 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.PluginInfrastructure { 25 [Serializable] 23 26 public class StartArgument : CommandLineArgument<string> { 24 27 public const string TOKEN = "start"; -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/CommandLineArgument.cs
r8748 r8818 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.PluginInfrastructure { 25 [Serializable] 23 26 public abstract class CommandLineArgument<T> : ICommandLineArgument<T> { 24 27 object ICommandLineArgument.Value { get { return Value; } } -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/CommandLineArgumentHandling.cs
r8748 r8818 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using System.Text.RegularExpressions; … … 43 44 private static ICommandLineArgument ParseArgument(string entry) { 44 45 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); 55 59 } 56 60 }
Note: See TracChangeset
for help on using the changeset viewer.