mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 10:55:30 +00:00
Variant: Add wrapper to construct "a{sv}" variant
This commit is contained in:
parent
cef9b13d72
commit
893703018f
|
@ -16,6 +16,7 @@
|
|||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GLib {
|
||||
|
||||
|
@ -170,6 +171,19 @@ namespace GLib {
|
|||
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)]
|
||||
static extern bool g_variant_get_boolean (IntPtr handle);
|
||||
|
||||
|
|
Loading…
Reference in a new issue