From 4158bc99f8d4b87fdb713e77f887876fed3fdc59 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 12 Jun 2014 16:48:03 -0400 Subject: [PATCH] Variant: Add Type property --- glib/Variant.cs | 12 ++++++++++++ sample/VariantDemo.cs | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/glib/Variant.cs b/glib/Variant.cs index bde56b665..2bb35be91 100644 --- a/glib/Variant.cs +++ b/glib/Variant.cs @@ -60,6 +60,18 @@ namespace GLib { this.handle = g_variant_ref_sink (handle); } + [DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr g_variant_get_type (IntPtr val); + + VariantType type; + public VariantType Type { + get { + if (type == null) + type = new VariantType (g_variant_get_type (Handle)); + return type; + } + } + [DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr g_variant_new_variant (IntPtr val); diff --git a/sample/VariantDemo.cs b/sample/VariantDemo.cs index f13b74b71..5d2f1481e 100644 --- a/sample/VariantDemo.cs +++ b/sample/VariantDemo.cs @@ -33,6 +33,8 @@ namespace sample var asv = variant.ToAsv (); Console.WriteLine ("strv: " + asv["strv"].Print(true)); Console.WriteLine ("unit: " + asv["unit"].Print(true)); + + Console.WriteLine ("type: " + variant.Type.ToString ()); } public static void Main (string[] args) @@ -40,4 +42,4 @@ namespace sample new VariantDemo (); } } -} \ No newline at end of file +}