You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Add Array and Dictionary wrapper classes to C#
(cherry picked from commit ee3c476c9a)
This commit is contained in:
committed by
Hein-Pieter van Braam
parent
e1cf8dc2cb
commit
31f8d3525d
@@ -1,36 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
internal static class MarshalUtils
|
||||
static class MarshalUtils
|
||||
{
|
||||
private static Dictionary<object, object> ArraysToDictionary(object[] keys, object[] values)
|
||||
static bool IsArrayGenericType(Type type)
|
||||
{
|
||||
var ret = new Dictionary<object, object>();
|
||||
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
ret.Add(keys[i], values[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return type.GetGenericTypeDefinition() == typeof(Array<>);
|
||||
}
|
||||
|
||||
private static void DictionaryToArrays(Dictionary<object, object> from, out object[] keysTo, out object[] valuesTo)
|
||||
static bool IsDictionaryGenericType(Type type)
|
||||
{
|
||||
var keys = from.Keys;
|
||||
keysTo = new object[keys.Count];
|
||||
keys.CopyTo(keysTo, 0);
|
||||
|
||||
var values = from.Values;
|
||||
valuesTo = new object[values.Count];
|
||||
values.CopyTo(valuesTo, 0);
|
||||
}
|
||||
|
||||
private static Type GetDictionaryType()
|
||||
{
|
||||
return typeof(Dictionary<object, object>);
|
||||
return type.GetGenericTypeDefinition() == typeof(Dictionary<, >);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user