virtualx-engine/modules/mono/glue/cs_files/MarshalUtils.cs

37 lines
958 B
C#
Raw Normal View History

using System;
2017-10-02 23:24:00 +02:00
using System.Collections.Generic;
namespace Godot
{
internal static class MarshalUtils
{
private static Dictionary<object, object> ArraysToDictionary(object[] keys, object[] values)
{
2018-04-08 05:30:43 +02:00
var ret = new Dictionary<object, object>();
2017-10-02 23:24:00 +02:00
for (int i = 0; i < keys.Length; i++)
2017-10-02 23:24:00 +02:00
{
ret.Add(keys[i], values[i]);
}
return ret;
}
private static void DictionaryToArrays(Dictionary<object, object> from, out object[] keysTo, out object[] valuesTo)
{
2018-04-08 05:30:43 +02:00
var keys = from.Keys;
2017-10-02 23:24:00 +02:00
keysTo = new object[keys.Count];
keys.CopyTo(keysTo, 0);
2018-04-08 05:30:43 +02:00
var values = from.Values;
2017-10-02 23:24:00 +02:00
valuesTo = new object[values.Count];
values.CopyTo(valuesTo, 0);
}
private static Type GetDictionaryType()
{
return typeof(Dictionary<object, object>);
}
}
}