/[gr2lib]/trunk/gr2lib_UnitTest/Program.cs
ViewVC logotype

Contents of /trunk/gr2lib_UnitTest/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69 - (show annotations) (download)
Thu Jul 15 09:29:25 2010 UTC (9 years, 6 months ago) by william
File size: 2358 byte(s)
fix commandline parsing

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 using gr2lib.core;
6 using gr2lib.core.apiversion;
7 using gr2lib.core.exceptions;
8 using gr2lib.core.helpers;
9
10 namespace gr2lib_UnitTest
11 {
12
13 class Program
14 {
15 static void Main(string[] args)
16 {
17 string GrannyFilename = shared.GRANNY_TEST_FILE;
18 try
19 {
20 // Setup access to check loaded Granny2 API Version
21 granny2apiversion apiversion = new granny2apiversion(shared.EXPECTED_API_VERSION);
22
23 // Check if the Loaded API Version Matches
24 if (!apiversion.apiversionsmatch)
25 {
26 // the loaded version does not match
27 Console.WriteLine("Warning:\n" +
28 "\t Loaded Granny2 DLL Version: " + apiversion.apiversion.version + "\n" +
29 "\t Expected Version: " + apiversion.expectedapiversion.version);
30 // return from void to exit application
31 return;
32 }
33 else
34 {
35 // the loaded version matches
36 Console.WriteLine("Loaded granny2.dll: " + apiversion.apiversion.version);
37 }
38
39 // parse commandline
40 if (args.Length == 1)
41 {
42 GrannyFilename = args[0];
43 }
44 else if (args.Length > 1)
45 {
46 throw new InvalidOperationException("ERROR: Recieved Invalid Commandline: " + new arraytostring<string,string[]>(args));
47 }
48
49 if (System.IO.File.Exists(GrannyFilename))
50 {
51 Console.WriteLine("Using Granny2 File: " + GrannyFilename);
52 }
53 else
54 {
55 throw new System.IO.FileNotFoundException("Unable to find: " + GrannyFilename);
56 }
57
58
59
60
61 }
62 catch (granny2apiloadexception ex)
63 {
64 Console.WriteLine(ex.Message);
65 }
66 catch (Exception ex)
67 {
68 Console.WriteLine(ex.Message);
69 }
70 }
71 }
72 }

  ViewVC Help
Powered by ViewVC 1.1.22