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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 william 97 //#define HAVE_GRN_REFERENCE // when defined enabled GRN_REFERNCE in Header, else it is disabled
2     using System;
3 william 94 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 william 97 #if HAVE_GRN_REFERENCE
13 william 94 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 william 102 catch
32 william 94 {
33     StackTrace st = new StackTrace(true);
34 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
35     Console.WriteLine(st.ToString());
36     #endif
37 william 94 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 william 102 catch
51 william 94 {
52     StackTrace st = new StackTrace(true);
53 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
54     Console.WriteLine(st.ToString());
55     #endif
56 william 94 return default(granny_reference);
57     }
58     }
59    
60 william 102 #region INativePointer Members
61 william 94 private IntPtr _NativePointer;
62     public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
63 william 102 #endregion
64 william 94
65 william 102 #region igranny_reference members
66 william 94 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 william 102 #endregion
72 william 94 }
73 william 97 #endif
74 william 94 }

  ViewVC Help
Powered by ViewVC 1.1.22