Variant: Add wrapper to construct "a{sv}" variant
This commit is contained in:
parent
cef9b13d72
commit
893703018f
1 changed files with 14 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace GLib {
|
namespace GLib {
|
||||||
|
|
||||||
|
@ -170,6 +171,19 @@ namespace GLib {
|
||||||
return new Variant (g_variant_new_dict_entry (k.Handle, v.Handle));
|
return new Variant (g_variant_new_dict_entry (k.Handle, v.Handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Variant (IDictionary<string, Variant> dict)
|
||||||
|
{
|
||||||
|
VariantType type = VariantType.NewDictionaryEntry (
|
||||||
|
VariantType.String,
|
||||||
|
VariantType.Variant);
|
||||||
|
|
||||||
|
var pairs = new List<Variant> ();
|
||||||
|
foreach (var kvp in dict)
|
||||||
|
pairs.Add (NewDictEntry (new Variant (kvp.Key), NewVariant (kvp.Value)));
|
||||||
|
|
||||||
|
handle = g_variant_ref_sink (NewArray (type, pairs.ToArray ()).Handle);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern bool g_variant_get_boolean (IntPtr handle);
|
static extern bool g_variant_get_boolean (IntPtr handle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue