/[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 97 - (hide annotations) (download)
Sat Jul 17 05:53:44 2010 UTC (9 years, 6 months ago) by william
File size: 2553 byte(s)
Add:
#define HAVE_GRN_REFERENCE
when defined enables GRN_REFERENCE class, else disables it (the code does not work)

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     catch (Exception ex)
32     {
33     StackTrace st = new StackTrace(true);
34     Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
35     return default(granny_reference);
36     }
37     }
38     internal static granny_reference ReadFromNative(gr2lib.core.coretypes.native.granny_grn_reference native)
39     {
40     try
41     {
42     granny_reference managed = new granny_reference();
43     //process reference
44     managed.SectionIndex = native.SectionIndex;
45     managed.Offset = native.Offset;
46     return managed;
47     }
48     catch (Exception ex)
49     {
50     StackTrace st = new StackTrace(true);
51     Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
52     return default(granny_reference);
53     }
54     }
55    
56     #region INativePointer Members
57     private IntPtr _NativePointer;
58     public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
59     #endregion
60    
61     #region igranny_reference members
62     private Int32 _SectionIndex;
63     private Int32 _Offset;
64    
65     public Int32 SectionIndex { get { return _SectionIndex; } set { _SectionIndex = value; } }
66     public Int32 Offset { get { return _Offset; } set { _Offset = value; } }
67     #endregion
68     }
69 william 97 #endif
70 william 94 }

  ViewVC Help
Powered by ViewVC 1.1.22