-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArguments.cs
55 lines (47 loc) · 1.58 KB
/
Arguments.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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Arguments.cs" company="Allberg Konsult AB">
// Allberg Konsult AB
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace NetworkRelay
{
using System;
using System.Collections.Generic;
/// <summary>
/// The arguments.
/// </summary>
internal class Arguments
{
/// <summary>
/// Initializes a new instance of the <see cref="Arguments"/> class.
/// </summary>
/// <param name="args">
/// The arguments.
/// </param>
public Arguments(string[] args)
{
// First argument is the hostname.
this.Hostname = args[0];
// The rest is port numbers
var ports = new List<int>();
for (var i = 1; i < args.Length; i++)
{
int somePort;
if (!int.TryParse(args[i], out somePort))
{
throw new ApplicationException(string.Format("\"{0}\" has to be a number between 1 and 65535", args[i]));
}
ports.Add(somePort);
}
this.Ports = ports;
}
/// <summary>
/// Gets the hostname.
/// </summary>
public string Hostname { get; private set; }
/// <summary>
/// Gets the ports.
/// </summary>
public IList<int> Ports { get; private set; }
}
}