Got at least one data fetching method working; turns out, we can't use a patched LogicStack to get the data
This commit is contained in:
29
Utils/Extensions.cs
Normal file
29
Utils/Extensions.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts;
|
||||
using Swan;
|
||||
|
||||
namespace RemoteControl.Utils
|
||||
{
|
||||
internal static class Extensions
|
||||
{
|
||||
internal static Dictionary<string, TEnum> AsLookupDict<TEnum, TValue>(this EnumCollection<TEnum, TValue> collection, bool lowercase)
|
||||
where TEnum : Enum, IConvertible, new()
|
||||
where TValue : IConvertible, IEquatable<TValue>
|
||||
{
|
||||
var result = new Dictionary<string, TEnum>();
|
||||
for (var i = 0; i < collection.Length; i++)
|
||||
{
|
||||
var name = collection.Names[i];
|
||||
if (lowercase)
|
||||
{
|
||||
name = name.ToLowerInvariant();
|
||||
}
|
||||
var value = collection.Values[i];
|
||||
result.Add(name, value);
|
||||
result.Add(collection.ValuesAsInts[i].ToStringInvariant(), value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user