/[gr2lib]/trunk/gr2lib/core/helpers/Helpers.cs
ViewVC logotype

Diff of /trunk/gr2lib/core/helpers/Helpers.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib/core/helpers/Helpers.cs	2010/07/17 05:10:22	95
+++ trunk/gr2lib/core/helpers/Helpers.cs	2010/07/17 05:11:13	96
@@ -4,6 +4,7 @@
 
 using gr2lib.core.coretypes.native;
 using System.Runtime.InteropServices;
+using System.Diagnostics;
 
 namespace gr2lib.core.helpers
 {
@@ -18,11 +19,14 @@
                     throw new InvalidOperationException();
                 }
 
-                return (T)Marshal.PtrToStructure(pointer, typeof(T));
+                T _object_implementation_ = (T)Marshal.PtrToStructure(pointer, typeof(T));
+
+                return _object_implementation_;
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(T);
             }
         }
@@ -35,7 +39,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(T[]);
             }
         }
@@ -54,7 +59,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(T[]);
             }
         }
@@ -67,7 +73,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(IntPtr[]);
             }
         }
@@ -86,7 +93,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(IntPtr[]);
             }
         }
@@ -99,7 +107,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(IntPtr[]);
             }
         }
@@ -117,7 +126,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.ToString());
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
                 return default(IntPtr[]);
             }
         }
@@ -163,18 +173,29 @@
 
         public static int SizeOfStruct<T>() where T : struct
         {
-            object[] attributes = typeof(T).GetCustomAttributes(false);
-            if (attributes == null || attributes.Length < 1) return 0;
-            int size = 0;
-            foreach (object attribute in attributes)
+            try
             {
-                if (attribute is SizeAttribute)
-                {
-                    size = (attribute as SizeAttribute).Size;
-                    break;
-                }
+
+                //object[] attributes = typeof(T).GetCustomAttributes(false);
+                //if (attributes == null || attributes.Length < 1) return 0;
+                int size = 0;
+                //foreach (object attribute in attributes)
+                //{
+                //    if (attribute is SizeAttribute)
+                //    {
+                //        size = (attribute as SizeAttribute).Size;
+                //        break;
+                //    }
+                //}
+                size = Marshal.SizeOf(typeof(T));
+                return size;
+            }
+            catch (Exception ex)
+            {
+                StackTrace st = new StackTrace(true);
+                Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
+                return 0;
             }
-            return size;
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22