Jypeli 10
The simple game programming library
Assert.cs
Siirry tämän tiedoston dokumentaatioon.
1using System;
2
3namespace Jypeli
4{
5 public partial class FileManager
6 {
7 public event Action<Exception> ReadAccessDenied;
8 public event Action<Exception> WriteAccessDenied;
9
10 private void OnAccessDenied( Exception e, bool write )
11 {
12 if ( !write && ReadAccessDenied != null )
14 if ( write && WriteAccessDenied != null )
16 }
17
18 protected void FMAssert( Action func, bool write )
19 {
20#if DEBUG
21 func();
22#else
23 try
24 {
25 func();
26 }
27 catch ( Exception e )
28 {
29 OnAccessDenied( e, write );
30 }
31#endif
32 }
33
34 protected void FMAssert<TP1>( Action<TP1> func, bool write, TP1 p1 )
35 {
36#if DEBUG
37 func( p1 );
38#else
39 try
40 {
41 func( p1 );
42 }
43 catch ( Exception e )
44 {
45 OnAccessDenied( e, write );
46 }
47#endif
48 }
49
50 protected TR FMAssert<TR>(Func<TR> func, bool write, TR defaultVal)
51 {
52#if DEBUG
53 return func();
54#else
55 try
56 {
57 return func();
58 }
59 catch ( Exception e )
60 {
61 OnAccessDenied( e, write );
62 }
63
64 return defaultVal;
65#endif
66 }
67
68 protected TR FMAssert<TP1, TR>( Func<TP1, TR> func, bool write, TR defaultVal, TP1 p1 )
69 {
70#if DEBUG
71 return func( p1 );
72#else
73 try
74 {
75 return func( p1 );
76 }
77 catch ( Exception e )
78 {
79 OnAccessDenied( e, write );
80 }
81
82 return defaultVal;
83#endif
84 }
85
86 protected TR FMAssert<TP1, TP2, TR>( Func<TP1, TP2, TR> func, bool write, TR defaultVal, TP1 p1, TP2 p2 )
87 {
88#if DEBUG
89 return func( p1, p2 );
90#else
91 try
92 {
93 return func( p1, p2 );
94 }
95 catch ( Exception e )
96 {
97 OnAccessDenied( e, write );
98 }
99
100 return defaultVal;
101#endif
102 }
103 }
104}
void FMAssert< TP1 >(Action< TP1 > func, bool write, TP1 p1)
Definition: Assert.cs:34
void FMAssert(Action func, bool write)
Definition: Assert.cs:18
TR FMAssert< TP1, TP2, TR >(Func< TP1, TP2, TR > func, bool write, TR defaultVal, TP1 p1, TP2 p2)
Definition: Assert.cs:86
void OnAccessDenied(Exception e, bool write)
Definition: Assert.cs:10
Action< Exception > WriteAccessDenied
Definition: Assert.cs:8
TR FMAssert< TP1, TR >(Func< TP1, TR > func, bool write, TR defaultVal, TP1 p1)
Definition: Assert.cs:68
TR FMAssert< TR >(Func< TR > func, bool write, TR defaultVal)
Definition: Assert.cs:50
Action< Exception > ReadAccessDenied
Definition: Assert.cs:7