From 7dd57040236dc34a313948f75b403a49df693649 Mon Sep 17 00:00:00 2001 From: Owen Fraser-Green Date: Thu, 25 Mar 2004 14:04:43 +0000 Subject: Added support for enumerations with marshalling to/from their underlying system type (Byte, Int32, UInt32, Int64, UInt64) --- mono/DBusType/Byte.cs | 8 ++++++++ mono/DBusType/Int32.cs | 11 +++++++++-- mono/DBusType/Int64.cs | 8 ++++++++ mono/DBusType/UInt32.cs | 8 ++++++++ mono/DBusType/UInt64.cs | 8 ++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) (limited to 'mono') diff --git a/mono/DBusType/Byte.cs b/mono/DBusType/Byte.cs index d5068f2e..a3d0ac9c 100644 --- a/mono/DBusType/Byte.cs +++ b/mono/DBusType/Byte.cs @@ -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&": diff --git a/mono/DBusType/Int32.cs b/mono/DBusType/Int32.cs index be78eba8..681a55f3 100644 --- a/mono/DBusType/Int32.cs +++ b/mono/DBusType/Int32.cs @@ -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&": diff --git a/mono/DBusType/Int64.cs b/mono/DBusType/Int64.cs index 1cc79c7c..741d272a 100644 --- a/mono/DBusType/Int64.cs +++ b/mono/DBusType/Int64.cs @@ -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&": diff --git a/mono/DBusType/UInt32.cs b/mono/DBusType/UInt32.cs index 43753511..e97aa37d 100644 --- a/mono/DBusType/UInt32.cs +++ b/mono/DBusType/UInt32.cs @@ -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": diff --git a/mono/DBusType/UInt64.cs b/mono/DBusType/UInt64.cs index 7bcccaee..84fef06b 100644 --- a/mono/DBusType/UInt64.cs +++ b/mono/DBusType/UInt64.cs @@ -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": -- cgit