-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (49 loc) · 1.82 KB
/
Program.cs
File metadata and controls
60 lines (49 loc) · 1.82 KB
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
using System;
using System.Collections.Generic;
internal class Program
{
private static readonly Dictionary<int, ISample> _samples = new Dictionary<int, ISample>
{
{1, new NetworkingSample()},
{2, new ComputeSample()},
};
private static void Main()
{
Console.Write("Identity Endpoint (e.g. http://104.130.30.68:5000/v2.0): ");
string identityEndpoint = Console.ReadLine();
Console.Write("User: ");
string username = Console.ReadLine();
Console.Write("Password: ");
string password = Console.ReadLine();
Console.Write("Project Name: ");
string project = Console.ReadLine();
Console.Write("Region [RegionOne]: ");
string region = Console.ReadLine();
if (string.IsNullOrEmpty(region))
region = "RegionOne";
Console.WriteLine("Available Samples: ");
Console.WriteLine("\t1. Networking");
Console.WriteLine("\t2. Compute");
Console.WriteLine();
Console.Write("Enter the example number to execute: ");
string requestedSample = Console.ReadLine();
int sampleId;
if (!(int.TryParse(requestedSample, out sampleId) && _samples.ContainsKey(sampleId)))
{
Console.WriteLine("Invalid sample requested. Exiting.");
}
else
{
ISample sample = _samples[sampleId];
Console.WriteLine();
sample.PrintTasks();
Console.WriteLine();
Console.Write("Do you want to proceed? [y/N]: ");
var shouldProceed = Console.ReadLine();
if (shouldProceed.ToLower() == "y")
sample.Run(identityEndpoint, username, password, project, region).Wait();
}
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
}
}