static object FixMono(Type enumType, object mono) { if (EnumPatcher.TryGetRawPatch(enumType, out var patch)) { var oldValues = (int[])values.GetValue(mono); var oldNames = (string[])names.GetValue(mono); patch.GetArrays(out string[] toBePatchedNames, out int[] toBePatchedValues); Array.Resize(ref toBePatchedNames, toBePatchedNames.Length + oldNames.Length); Array.Resize(ref toBePatchedValues, toBePatchedValues.Length + oldValues.Length); Array.Copy(oldNames, 0, toBePatchedNames, toBePatchedNames.Length - oldNames.Length, oldNames.Length); Array.Copy(oldValues, 0, toBePatchedValues, toBePatchedValues.Length - oldValues.Length, oldValues.Length); names.SetValue(mono, toBePatchedNames); values.SetValue(mono, toBePatchedValues); } return(mono); }
static void FixEnum(object type, ref ulong[] oldValues, ref string[] oldNames) { var enumType = type as Type; if (EnumPatcher.TryGetRawPatch(enumType, out var patch)) { patch.GetArrays(out string[] toBePatchedNames, out ulong[] toBePatchedValues); Array.Resize(ref toBePatchedNames, toBePatchedNames.Length + oldNames.Length); Array.Resize(ref toBePatchedValues, toBePatchedValues.Length + oldValues.Length); Array.Copy(oldNames, 0, toBePatchedNames, toBePatchedNames.Length - oldNames.Length, oldNames.Length); Array.Copy(oldValues, 0, toBePatchedValues, toBePatchedValues.Length - oldValues.Length, oldValues.Length); oldValues = toBePatchedValues; oldNames = toBePatchedNames; Array.Sort <ulong, string>(oldValues, oldNames, Comparer <ulong> .Default); } }