Links
Download
I have found no way to download the
Mono.GetOptions.dll directly; you will get the dll by
downloading Mono (choose "Mono 2.0 Setup"). You may find the dll in
C:\Program Files\Mono-2.0\lib\mono\2.0\ — if you do not, simply search for it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.GetOptions;
using System.IO;
namespace ThreadedSqlExecutor
{ class Program
{
class Opts : Options
{
[Option("input file", 'f')]
public string FileName { get; protected set; }
[Option("max threads", 't')]
public int MaxThreads { get; protected set; }
[Option("minimum period in ms", 'p')]
public int MinimumPeriod { get; protected set; }
[Option("connection string", 'c')]
public string ConnectionString { get; protected set; }
[Option("staggered start", "staggered")]
public bool StaggeredStart { get; protected set; }
}
static void Main(string[] args)
{
Opts opts = new Opts();
opts.ProcessArgs(args);
Action<string> errorAndExit = msg =>
{
Console.Error.WriteLine(msg);
Environment.Exit(-1);
};
if (!File.Exists(opts.FileName))
errorAndExit("valid file not specified");
Sample invocations
ThreadedSqlExecutor c:\input.txt 3 9 "connection string with spaces" -staggered
ThreadedSqlExecutor -f c:\input.txt -t 3 -p 9 -c "connection string with spaces" -staggered
Notes
ilmerge can be used to combine the
GetOptions dll with the
exe.