/[gr2lib]/trunk/gr2lib/core/coretypes/implementation/Map.cs
ViewVC logotype

Annotation of /trunk/gr2lib/core/coretypes/implementation/Map.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 196 - (hide annotations) (download)
Thu Jul 29 07:47:26 2010 UTC (11 years, 5 months ago) by william
File size: 2924 byte(s)
bulk commit

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 william 186
12     /// <summary>
13     /// Map class
14     /// </summary>
15 william 79 public class Map : IMap
16     {
17 william 186 /// <summary>
18 william 196 /// Gets the string representation of this instance
19     /// </summary>
20     /// <returns></returns>
21     public override string ToString()
22     {
23     return this.Usage;
24     }
25     /// <summary>
26 william 186 /// default constructor
27     /// </summary>
28 william 80 public Map()
29     {
30 william 83 //this.NativePointer = IntPtr.Zero;
31     //this.MapPointer = IntPtr.Zero;
32 william 80 this.Usage = "";
33     }
34 william 79 internal static Map ReadFromMemory(IntPtr pointer)
35     {
36 william 86 try
37     {
38 william 79 if (pointer == IntPtr.Zero) return null;
39     native.Map native = Helpers.ReadFromMemory<native.Map>(pointer);
40     Map managed = ReadFromNative(native);
41     managed.NativePointer = pointer;
42     return managed;
43 william 86 }
44 william 106 catch (Exception ex)
45 william 86 {
46 william 95 StackTrace st = new StackTrace(true);
47 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
48 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
49 william 102 #endif
50 william 86 return default(Map);
51     }
52 william 79 }
53    
54     internal static Map ReadFromNative(native.Map native)
55     {
56 william 86 try
57     {
58 william 79 Map managed = new Map();
59     managed.Usage = native.Usage;
60     managed.MapPointer = native.MapPointer;
61     return managed;
62 william 86 }
63 william 106 catch (Exception ex)
64 william 86 {
65 william 95 StackTrace st = new StackTrace(true);
66 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
67 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
68 william 102 #endif
69 william 86 return default(Map);
70     }
71 william 79 }
72    
73     #region INativePointer Members
74     private IntPtr _NativePointer;
75 william 181 /// <summary>
76     /// When used in a derived class, gets the native pointer for this instance
77     /// </summary>
78 william 79 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
79     #endregion
80    
81 william 181
82 william 79 #region IMap Members
83     private string _Usage;
84     private IntPtr _MapPointer;
85    
86 william 186 /// <summary>
87     /// Get or Set the map ussage for this insance
88     /// </summary>
89 william 79 public string Usage { get { return _Usage; } set { _Usage = value; } }
90 william 186 /// <summary>
91     /// Get or set the map pointer for this instance
92     /// </summary>
93 william 79 public IntPtr MapPointer { get { return _MapPointer; } set { _MapPointer = value; } }
94     #endregion
95     }
96     }

  ViewVC Help
Powered by ViewVC 1.1.22