/[gr2lib]/trunk/gr2lib/core/coreclasses/header/granny_reference.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coreclasses/header/granny_reference.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (show annotations) (download)
Sat Jul 17 13:54:18 2010 UTC (9 years, 1 month ago) by william
File size: 2512 byte(s)
add compiler directive to write exceptions to console or not

1 //#define HAVE_GRN_REFERENCE // when defined enabled GRN_REFERNCE in Header, else it is disabled
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using gr2lib.core.interfaces;
7 using System.Diagnostics;
8 using gr2lib.core.helpers;
9
10 namespace gr2lib.core.coreclasses.header
11 {
12 #if HAVE_GRN_REFERENCE
13 public class granny_reference : igranny_reference
14 {
15
16 public granny_reference()
17 {
18 this.SectionIndex = 0;
19 this.Offset = 0;
20 }
21 internal static granny_reference ReadFromMemory(IntPtr pointer)
22 {
23 try
24 {
25 if (pointer == IntPtr.Zero) return null;
26 gr2lib.core.coretypes.native.granny_grn_reference native = Helpers.ReadFromMemory<gr2lib.core.coretypes.native.granny_grn_reference>(pointer);
27 granny_reference managed = ReadFromNative(native);
28 managed.NativePointer = pointer;
29 return managed;
30 }
31 catch
32 {
33 StackTrace st = new StackTrace(true);
34 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
35 Console.WriteLine(st.ToString());
36 #endif
37 return default(granny_reference);
38 }
39 }
40 internal static granny_reference ReadFromNative(gr2lib.core.coretypes.native.granny_grn_reference native)
41 {
42 try
43 {
44 granny_reference managed = new granny_reference();
45 //process reference
46 managed.SectionIndex = native.SectionIndex;
47 managed.Offset = native.Offset;
48 return managed;
49 }
50 catch
51 {
52 StackTrace st = new StackTrace(true);
53 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
54 Console.WriteLine(st.ToString());
55 #endif
56 return default(granny_reference);
57 }
58 }
59
60 #region INativePointer Members
61 private IntPtr _NativePointer;
62 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
63 #endregion
64
65 #region igranny_reference members
66 private Int32 _SectionIndex;
67 private Int32 _Offset;
68
69 public Int32 SectionIndex { get { return _SectionIndex; } set { _SectionIndex = value; } }
70 public Int32 Offset { get { return _Offset; } set { _Offset = value; } }
71 #endregion
72 }
73 #endif
74 }

  ViewVC Help
Powered by ViewVC 1.1.22