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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22