-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathArgumentParser.cs
69 lines (60 loc) · 1.56 KB
/
ArgumentParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
namespace png2bmp32
{
/// <summary>
/// Event argument class.
/// </summary>
class PathParsedEventArgs : EventArgs
{
public string Path { get; private set; }
public PathParsedEventArgs(string path)
{
Path = path;
}
}
/// <summary>
/// …
/// </summary>
class ArgumentParser
{
public string[] Args { get; private set; }
/// <summary>
/// …
/// </summary>
/// <param name="args">…</param>
public ArgumentParser(string[] args)
{
Args = args;
}
public event EventHandler<PathParsedEventArgs> InputPathParsed;
public event EventHandler FinishedArgumentParsing;
/// <summary>
/// …
/// </summary>
/// <param name="e">…</param>
protected virtual void OnInputPathParsed(PathParsedEventArgs e)
{
if (InputPathParsed == null) return;
InputPathParsed(this, e);
}
/// <summary>
/// …
/// </summary>
/// <param name="e">…</param>
protected virtual void OnFinishedArgumentParsing(EventArgs e)
{
if (FinishedArgumentParsing == null) return;
FinishedArgumentParsing(this, e);
}
/// <summary>
/// …
/// </summary>
internal void Parse()
{
if (Args.Length != 1) throw new Exception(Properties.Resource.strCmdLnParamCount);
OnInputPathParsed(new PathParsedEventArgs(Args[0]));
OnFinishedArgumentParsing(new EventArgs());
}
}
}