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

# User Rev Content
1 william 79 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 william 95 using System.Diagnostics;
8 william 106 using gr2lib.core.exceptions;
9 william 79 namespace gr2lib.core.coretypes.implementation
10     {
11     public class Map : IMap
12     {
13 william 80 public Map()
14     {
15 william 83 //this.NativePointer = IntPtr.Zero;
16     //this.MapPointer = IntPtr.Zero;
17 william 80 this.Usage = "";
18     }
19 william 79 internal static Map ReadFromMemory(IntPtr pointer)
20     {
21 william 86 try
22     {
23 william 79 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 william 86 }
29 william 106 catch (Exception ex)
30 william 86 {
31 william 95 StackTrace st = new StackTrace(true);
32 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
33 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
34 william 102 #endif
35 william 86 return default(Map);
36     }
37 william 79 }
38    
39     internal static Map ReadFromNative(native.Map native)
40     {
41 william 86 try
42     {
43 william 79 Map managed = new Map();
44     managed.Usage = native.Usage;
45     managed.MapPointer = native.MapPointer;
46     return managed;
47 william 86 }
48 william 106 catch (Exception ex)
49 william 86 {
50 william 95 StackTrace st = new StackTrace(true);
51 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
52 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
53 william 102 #endif
54 william 86 return default(Map);
55     }
56 william 79 }
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     }