Added support for enumerations with marshalling to/from their underlying system type...
authorOwen Fraser-Green <owen@discobabe.net>
Thu, 25 Mar 2004 14:04:43 +0000 (14:04 +0000)
committerOwen Fraser-Green <owen@discobabe.net>
Thu, 25 Mar 2004 14:04:43 +0000 (14:04 +0000)
mono/DBusType/Byte.cs
mono/DBusType/Int32.cs
mono/DBusType/Int64.cs
mono/DBusType/UInt32.cs
mono/DBusType/UInt64.cs

index d5068f2..a3d0ac9 100644 (file)
@@ -41,6 +41,10 @@ namespace DBus.DBusType
 
     public static bool Suits(System.Type type) 
     {
+      if (type.IsEnum && type.UnderlyingSystemType == typeof(System.Byte)) {
+       return true;
+      }
+
       switch (type.ToString()) {
       case "System.Byte":
       case "System.Byte&":
@@ -75,6 +79,10 @@ namespace DBus.DBusType
 
     public object Get(System.Type type)
     {
+      if (type.IsEnum) {
+       return Enum.ToObject(type, this.val);
+      }
+
       switch (type.ToString()) {
       case "System.Byte":
       case "System.Byte&":
index be78eba..681a55f 100644 (file)
@@ -36,11 +36,14 @@ namespace DBus.DBusType
 
     public static bool Suits(System.Type type) 
     {
+      if (type.IsEnum && type.UnderlyingSystemType == typeof(System.Int32)) {
+       return true;
+      }
+      
       switch (type.ToString()) {
       case "System.Int32":
       case "System.Int32&":
-       return true;
-      }
+       return true;      }
       
       return false;
     }
@@ -68,6 +71,10 @@ namespace DBus.DBusType
 
     public object Get(System.Type type)
     {
+      if (type.IsEnum) {
+       return Enum.ToObject(type, this.val);
+      }
+      
       switch (type.ToString()) {
       case "System.Int32":
       case "System.Int32&":
index 1cc79c7..741d272 100644 (file)
@@ -36,6 +36,10 @@ namespace DBus.DBusType
 
     public static bool Suits(System.Type type) 
     {
+      if (type.IsEnum && type.UnderlyingSystemType == typeof(System.Int64)) {
+       return true;
+      }
+
       switch (type.ToString()) {
       case "System.Int64":
       case "System.Int64&":
@@ -68,6 +72,10 @@ namespace DBus.DBusType
 
     public object Get(System.Type type)
     {
+      if (type.IsEnum) {
+       return Enum.ToObject(type, this.val);
+      }
+
       switch (type.ToString()) {
       case "System.Int64":
       case "System.Int64&":
index 4375351..e97aa37 100644 (file)
@@ -36,6 +36,10 @@ namespace DBus.DBusType
 
     public static bool Suits(System.Type type) 
     {
+      if (type.IsEnum && type.UnderlyingSystemType == typeof(System.UInt32)) {
+       return true;
+      }
+
       switch (type.ToString()) {
       case "System.UInt32":
       case "System.UInt32&":
@@ -68,6 +72,10 @@ namespace DBus.DBusType
 
     public object Get(System.Type type)
     {
+      if (type.IsEnum) {
+       return Enum.ToObject(type, this.val);
+      }
+
       switch (type.ToString()) 
        {
        case "System.UInt32":
index 7bcccae..84fef06 100644 (file)
@@ -36,6 +36,10 @@ namespace DBus.DBusType
 
     public static bool Suits(System.Type type) 
     {
+      if (type.IsEnum && type.UnderlyingSystemType == typeof(System.UInt64)) {
+       return true;
+      }
+
       switch (type.ToString()) {
       case "System.UInt64":
       case "System.UInt64&":
@@ -68,6 +72,10 @@ namespace DBus.DBusType
 
     public object Get(System.Type type)
     {
+      if (type.IsEnum) {
+       return Enum.ToObject(type, this.val);
+      }
+
       switch (type.ToString()) 
        {
        case "System.UInt64":