Variant: Add Type property

This commit is contained in:
Xavier Claessens 2014-06-12 16:48:03 -04:00
parent dc0f50729a
commit 4158bc99f8
2 changed files with 15 additions and 1 deletions

View file

@ -60,6 +60,18 @@ namespace GLib {
this.handle = g_variant_ref_sink (handle); 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)] [DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_variant_new_variant (IntPtr val); static extern IntPtr g_variant_new_variant (IntPtr val);

View file

@ -33,6 +33,8 @@ namespace sample
var asv = variant.ToAsv (); var asv = variant.ToAsv ();
Console.WriteLine ("strv: " + asv["strv"].Print(true)); Console.WriteLine ("strv: " + asv["strv"].Print(true));
Console.WriteLine ("unit: " + asv["unit"].Print(true)); Console.WriteLine ("unit: " + asv["unit"].Print(true));
Console.WriteLine ("type: " + variant.Type.ToString ());
} }
public static void Main (string[] args) public static void Main (string[] args)