ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/gr2lib/trunk/gr2lib/core/coretypes/implementation/Map.cs
Revision: 106
Committed: Sat Jul 17 14:52:37 2010 UTC (12 years, 4 months ago) by william
File size: 2204 byte(s)
Log Message:
implement Granny2ExceptionWriter

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using gr2lib.core.helpers;
6 using gr2lib.core.interfaces;
7 using System.Diagnostics;
8 using gr2lib.core.exceptions;
9 namespace gr2lib.core.coretypes.implementation
10 {
11 public class Map : IMap
12 {
13 public Map()
14 {
15 //this.NativePointer = IntPtr.Zero;
16 //this.MapPointer = IntPtr.Zero;
17 this.Usage = "";
18 }
19 internal static Map ReadFromMemory(IntPtr pointer)
20 {
21 try
22 {
23 if (pointer == IntPtr.Zero) return null;
24 native.Map native = Helpers.ReadFromMemory<native.Map>(pointer);
25 Map managed = ReadFromNative(native);
26 managed.NativePointer = pointer;
27 return managed;
28 }
29 catch (Exception ex)
30 {
31 StackTrace st = new StackTrace(true);
32 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
33 Granny2ExceptionWriter.WriteToConsole(ex,st);
34 #endif
35 return default(Map);
36 }
37 }
38
39 internal static Map ReadFromNative(native.Map native)
40 {
41 try
42 {
43 Map managed = new Map();
44 managed.Usage = native.Usage;
45 managed.MapPointer = native.MapPointer;
46 return managed;
47 }
48 catch (Exception ex)
49 {
50 StackTrace st = new StackTrace(true);
51 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
52 Granny2ExceptionWriter.WriteToConsole(ex,st);
53 #endif
54 return default(Map);
55 }
56 }
57
58 #region INativePointer Members
59 private IntPtr _NativePointer;
60 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
61 #endregion
62
63 #region IMap Members
64 private string _Usage;
65 private IntPtr _MapPointer;
66
67 public string Usage { get { return _Usage; } set { _Usage = value; } }
68 public IntPtr MapPointer { get { return _MapPointer; } set { _MapPointer = value; } }
69 #endregion
70 }
71 }