1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Text; |
4 |
using System.Windows.Forms; |
5 |
using System.Runtime.Serialization; |
6 |
|
7 |
namespace gr2lib.core.exceptions |
8 |
{ |
9 |
|
10 |
|
11 |
#region Granny2 API Load Exceptions |
12 |
|
13 |
#region public class granny2apiloadexception |
14 |
[Serializable()] |
15 |
public class granny2apiloadexception : System.Exception, ISerializable |
16 |
{ |
17 |
private const string error_message = "ERROR: Unable to load granny2 API"; |
18 |
public granny2apiloadexception() : this(new granny2dllnotfoundexception()) { } |
19 |
private granny2apiloadexception(Exception inner) : base(error_message, inner) { } |
20 |
protected granny2apiloadexception(SerializationInfo info, StreamingContext context) : base(info, context) { } |
21 |
|
22 |
public override string Message |
23 |
{ |
24 |
get |
25 |
{ |
26 |
return error_message + "\n" + |
27 |
"REASON: " + this.InnerException.Message; |
28 |
} |
29 |
} |
30 |
|
31 |
#region private class granny2dllnotfoundexception |
32 |
[Serializable()] |
33 |
private class granny2dllnotfoundexception : System.Exception, ISerializable |
34 |
{ |
35 |
public override string Message |
36 |
{ |
37 |
get |
38 |
{ |
39 |
return this.InnerException.Message + " was not found."; |
40 |
} |
41 |
} |
42 |
|
43 |
public granny2dllnotfoundexception() : this(new System.IO.FileNotFoundException(core.sharedio.granny_dll)) { } |
44 |
private granny2dllnotfoundexception(Exception inner) : base("", inner) { } |
45 |
protected granny2dllnotfoundexception(SerializationInfo info, StreamingContext context) : base(info, context) { } |
46 |
} |
47 |
#endregion |
48 |
} |
49 |
|
50 |
#endregion |
51 |
|
52 |
|
53 |
#region public class granny2apiloader |
54 |
public class granny2apiloader |
55 |
{ |
56 |
string application_path; |
57 |
public granny2apiloader() |
58 |
{ |
59 |
application_path = Application.StartupPath; |
60 |
|
61 |
if (!System.IO.File.Exists(core.sharedio.granny_dll)) |
62 |
{ |
63 |
throw new granny2apiloadexception(); |
64 |
} |
65 |
|
66 |
} |
67 |
} |
68 |
#endregion |
69 |
|
70 |
#endregion |
71 |
} |
72 |
|