using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInExUtils.Attributes;
using BepInExUtils.Interfaces;
using BepInExUtils.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("BepInExUtils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+be66c586b5eb68b50fbdc6822a2dc2f27e6b474d")]
[assembly: AssemblyProduct("BepInExUtils")]
[assembly: AssemblyTitle("BepInExUtils")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInExUtils
{
[BepInUtils("io.github.ykysnk.BepinExUtils", "BepInEx Utils", "1.0.2")]
[BepInPlugin("io.github.ykysnk.BepinExUtils", "BepInEx Utils", "1.0.2")]
public class Main : BaseUnityPlugin, IBepInUtils
{
private const string Version = "1.0.2";
private static Main? _instance;
private readonly Harmony _harmony = new Harmony("io.github.ykysnk.BepinExUtils");
public void Init()
{
}
public Main()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_instance = this;
Configs.Init();
Utils.Logger.Info("Plugin BepInEx Utils is loaded, version 1.0.2");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
Init();
}
}
[PublicAPI]
public static class MethodUtils
{
private const string UnknownName = "Unknown";
public static string CallerName => GetCallerName(2);
public static string MethodName => GetMethodName(1);
public static string GetCallerName(int index = 1)
{
int index2 = index + 1;
StackFrame frame = new StackTrace().GetFrame(index2);
if (frame == null)
{
return "Unknown";
}
MethodBase method = frame.GetMethod();
if (method == null)
{
return "Unknown";
}
return method.DeclaringType?.Name ?? method.Name;
}
public static string GetMethodName(int index = 0)
{
int index2 = index + 1;
StackFrame frame = new StackTrace().GetFrame(index2);
if (frame == null)
{
return "Unknown";
}
MethodBase method = frame.GetMethod();
if (!(method == null))
{
return method.Name;
}
return "Unknown";
}
}
internal static class Utils
{
internal const string Guid = "io.github.ykysnk.BepinExUtils";
internal const string Name = "BepInEx Utils";
internal const string Version = "1.0.2";
private static Logger? _logger;
public static Logger Logger => _logger ?? (_logger = new Logger("BepInEx Utils"));
}
public static class Configs
{
internal static void Init()
{
}
}
}
namespace BepInExUtils.Proxy
{
[PublicAPI]
public abstract class ClassProxy
{
protected readonly Type Type;
[Obsolete("Use Native instead.")]
protected object Instance => Native;
public object Native { get; }
protected ClassProxy(object? instance, string className)
{
if (string.IsNullOrEmpty(className))
{
throw new ArgumentException("Class name cannot be null or empty", "className");
}
Type = AccessTools.TypeByName(className);
if (Type == null)
{
throw new TypeAccessException("Type " + className + " not found.");
}
if (Type.BaseType == GetType())
{
throw new TypeAccessException("Type " + className + " is subclass of " + GetType().Name + ".");
}
Type type = instance?.GetType();
if (type != Type)
{
throw new TypeAccessException("instance " + type?.FullName + " is not match " + Type.FullName + ".");
}
Native = instance ?? throw new NullReferenceException("instance is null");
}
protected ClassProxy(string className)
{
if (string.IsNullOrEmpty(className))
{
throw new ArgumentException("Class name cannot be null or empty", "className");
}
Type = AccessTools.TypeByName(className);
if (Type == null)
{
throw new TypeAccessException("Type " + className + " not found.");
}
if (Type.BaseType == GetType())
{
throw new TypeAccessException("Type " + className + " is subclass of " + GetType().Name + ".");
}
if (Type.IsAbstract)
{
throw new TypeAccessException("Type " + className + " is abstract class.");
}
Native = Activator.CreateInstance(Type) ?? throw new NullReferenceException("Could not create instance");
}
protected ClassProxy(string className, params object[] args)
{
if (string.IsNullOrEmpty(className))
{
throw new ArgumentException("Class name cannot be null or empty", "className");
}
Type = AccessTools.TypeByName(className);
if (Type == null)
{
throw new TypeAccessException("Type " + className + " not found.");
}
if (Type.BaseType == GetType())
{
throw new TypeAccessException("Type " + className + " is subclass of " + GetType().Name + ".");
}
if (Type.IsAbstract)
{
throw new TypeAccessException("Type " + className + " is abstract class.");
}
Native = Activator.CreateInstance(Type, args) ?? throw new NullReferenceException("Could not create instance");
}
protected ClassProxy(string className, object[] args, object[] activationAttributes)
{
if (string.IsNullOrEmpty(className))
{
throw new ArgumentException("Class name cannot be null or empty", "className");
}
Type = AccessTools.TypeByName(className);
if (Type == null)
{
throw new TypeAccessException("Type " + className + " not found.");
}
if (Type.BaseType == GetType())
{
throw new TypeAccessException("Type " + className + " is subclass of " + GetType().Name + ".");
}
if (Type.IsAbstract)
{
throw new TypeAccessException("Type " + className + " is abstract class.");
}
Native = Activator.CreateInstance(Type, args, activationAttributes) ?? throw new NullReferenceException("Could not create instance");
}
}
}
namespace BepInExUtils.Logging
{
[PublicAPI]
public class AsyncLogSource : ILogSource, IDisposable
{
public string SourceName { get; }
public event EventHandler<LogEventArgs>? LogEvent;
public AsyncLogSource(string sourceName)
{
SourceName = sourceName;
base..ctor();
}
public void Dispose()
{
}
public async Task Log(LogLevel level, object data)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
object data2 = data;
await Task.Run(delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
this.LogEvent?.Invoke(this, new LogEventArgs(data2, level, (ILogSource)(object)this));
});
}
public async Task LogFatal(object data)
{
await Log((LogLevel)1, data);
}
public async Task LogError(object data)
{
await Log((LogLevel)2, data);
}
public async Task LogWarning(object data)
{
await Log((LogLevel)4, data);
}
public async Task LogMessage(object data)
{
await Log((LogLevel)8, data);
}
public async Task LogInfo(object data)
{
await Log((LogLevel)16, data);
}
public async Task LogDebug(object data)
{
await Log((LogLevel)32, data);
}
}
[PublicAPI]
public class Logger
{
[CompilerGenerated]
private string <sourceName>P;
private const string LogFormat = "[{0}] {1}";
private AsyncLogSource? _logger;
private AsyncLogSource LogSource => _logger ?? (_logger = CreateAsyncLogSource(<sourceName>P));
public Logger(string sourceName)
{
<sourceName>P = sourceName;
base..ctor();
}
public static AsyncLogSource CreateAsyncLogSource(string sourceName)
{
AsyncLogSource asyncLogSource = new AsyncLogSource(sourceName);
Logger.Sources.Add((ILogSource)(object)asyncLogSource);
return asyncLogSource;
}
public void LogError(object data)
{
LogSource.LogError($"[{MethodUtils.CallerName}] {data}");
}
public async Task LogErrorAsync(object data)
{
await LogSource.LogError($"[{MethodUtils.CallerName}] {data}");
}
public void LogDebug(object data)
{
LogSource.LogDebug($"[{MethodUtils.CallerName}] {data}");
}
public async Task LogDebugAsync(object data)
{
await LogSource.LogDebug($"[{MethodUtils.CallerName}] {data}");
}
public void LogWarning(object data)
{
LogSource.LogWarning($"[{MethodUtils.CallerName}] {data}");
}
public async Task LogWarningAsync(object data)
{
await LogSource.LogWarning($"[{MethodUtils.CallerName}] {data}");
}
public void LogFatal(object data)
{
LogSource.LogFatal($"[{MethodUtils.CallerName}] {data}");
}
public async Task LogFatalAsync(object data)
{
await LogSource.LogFatal($"[{MethodUtils.CallerName}] {data}");
}
public void LogInfo(object data)
{
LogSource.LogInfo($"[{MethodUtils.CallerName}] {data}");
}
public async Task LogInfoAsync(object data)
{
await LogSource.LogInfo($"[{MethodUtils.CallerName}] {data}");
}
public void LogMessage(object data)
{
LogSource.LogMessage($"[{MethodUtils.CallerName}] {data}");
}
public async Task LogMessageAsync(object data)
{
await LogSource.LogMessage($"[{MethodUtils.CallerName}] {data}");
}
public void Error(object data)
{
LogSource.LogError($"[{MethodUtils.CallerName}] {data}");
}
public async Task ErrorAsync(object data)
{
await LogSource.LogError($"[{MethodUtils.CallerName}] {data}");
}
public void Debug(object data)
{
LogSource.LogDebug($"[{MethodUtils.CallerName}] {data}");
}
public async Task DebugAsync(object data)
{
await LogSource.LogDebug($"[{MethodUtils.CallerName}] {data}");
}
public void Warning(object data)
{
LogSource.LogWarning($"[{MethodUtils.CallerName}] {data}");
}
public async Task WarningAsync(object data)
{
await LogSource.LogWarning($"[{MethodUtils.CallerName}] {data}");
}
public void Fatal(object data)
{
LogSource.LogFatal($"[{MethodUtils.CallerName}] {data}");
}
public async Task FatalAsync(object data)
{
await LogSource.LogFatal($"[{MethodUtils.CallerName}] {data}");
}
public void Info(object data)
{
LogSource.LogInfo($"[{MethodUtils.CallerName}] {data}");
}
public async Task InfoAsync(object data)
{
await LogSource.LogInfo($"[{MethodUtils.CallerName}] {data}");
}
public void Message(object data)
{
LogSource.LogMessage($"[{MethodUtils.CallerName}] {data}");
}
public async Task MessageAsync(object data)
{
await LogSource.LogMessage($"[{MethodUtils.CallerName}] {data}");
}
}
}
namespace BepInExUtils.Interfaces
{
[PublicAPI]
[Obsolete("Use IBepInUtils instead")]
public abstract class BepInUtilsUnityPlugin : BaseUnityPlugin
{
protected abstract void PostAwake();
}
[PublicAPI]
public interface IBepInUtils
{
void Init();
}
}
namespace BepInExUtils.Extensions
{
public static class AssemblyExtensions
{
public sealed class <>E__0
{
[PublicAPI]
private Stream GetManifestResourceStreamOrThrow(string resource)
{
throw null;
}
[PublicAPI]
public string GetEmbeddedResource(string resource)
{
throw null;
}
[PublicAPI]
public byte[] GetEmbeddedResourceBytes(string resource)
{
throw null;
}
[PublicAPI]
public AssetBundle GetEmbeddedAssetBundle(string resource)
{
throw null;
}
[PublicAPI]
public bool LoadEmbeddedImage(ref Texture2D tex, string resource)
{
throw null;
}
}
[SpecialName]
[PublicAPI]
private static Stream GetManifestResourceStreamOrThrow(this Assembly assembly, string resource)
{
return assembly.GetManifestResourceStream(resource) ?? throw new Exception(string.Format("Failed to find EmbeddedResource '{0}' in Assembly '{1}' (Available Resources: {2})", resource, assembly, string.Join(", ", assembly.GetManifestResourceNames())));
}
[SpecialName]
[PublicAPI]
public static string GetEmbeddedResource(this Assembly assembly, string resource)
{
using StreamReader streamReader = new StreamReader(assembly.GetManifestResourceStreamOrThrow(resource));
return streamReader.ReadToEnd();
}
[SpecialName]
[PublicAPI]
public static byte[] GetEmbeddedResourceBytes(this Assembly assembly, string resource)
{
using Stream stream = assembly.GetManifestResourceStreamOrThrow(resource);
using MemoryStream memoryStream = new MemoryStream();
byte[] array = new byte[stream.Length];
int count;
while ((count = stream.Read(array, 0, array.Length)) != 0)
{
memoryStream.Write(array, 0, count);
}
return memoryStream.ToArray();
}
[SpecialName]
[PublicAPI]
public static AssetBundle GetEmbeddedAssetBundle(this Assembly assembly, string resource)
{
using Stream stream = assembly.GetManifestResourceStreamOrThrow(resource);
return AssetBundle.LoadFromStream(stream);
}
[SpecialName]
[PublicAPI]
public static bool LoadEmbeddedImage(this Assembly assembly, ref Texture2D tex, string resource)
{
return ImageConversion.LoadImage(tex, assembly.GetEmbeddedResourceBytes(resource));
}
}
public static class ComponentExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public string? FullName()
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static string? FullName(this Component obj)
{
if (Object.op_Implicit((Object)(object)obj))
{
return obj.gameObject.FullName();
}
return null;
}
}
public static class ConfigEntryExtensions
{
public sealed class <>E__0<T>
{
[PublicAPI]
public ConfigEntryEx<T> TryGetValue(T defaultValue = default(T))
{
throw null;
}
[PublicAPI]
public ConfigEntryEx<T> Value()
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static ConfigEntryEx<T> TryGetValue<T>(this ConfigEntry<T>? configEntry, T defaultValue = default(T))
{
return new ConfigEntryEx<T>(configEntry, defaultValue);
}
[SpecialName]
[PublicAPI]
public static ConfigEntryEx<T> Value<T>(this ConfigEntry<T>? configEntry)
{
T val = (T)((configEntry != null) ? ((ConfigEntryBase)configEntry).DefaultValue : null);
return configEntry.TryGetValue((val != null) ? val : default(T));
}
}
[PublicAPI]
public class ConfigEntryEx<T>
{
[CompilerGenerated]
private ConfigEntry<T>? <configEntry>P;
[CompilerGenerated]
private T <defaultValue>P;
private T Value
{
get
{
if (<configEntry>P != null)
{
return <configEntry>P.Value;
}
return <defaultValue>P;
}
}
public T V
{
get
{
return Value;
}
set
{
Set(value);
}
}
public ConfigEntryEx(ConfigEntry<T>? configEntry, T defaultValue = default(T))
{
<configEntry>P = configEntry;
<defaultValue>P = defaultValue;
base..ctor();
}
public void Set(T value)
{
if (<configEntry>P != null)
{
<configEntry>P.Value = value;
}
}
public static implicit operator T(ConfigEntryEx<T> instance)
{
return instance.Value;
}
public static explicit operator ConfigEntryEx<T>(ConfigEntry<T>? configEntry)
{
return new ConfigEntryEx<T>(configEntry);
}
}
public static class DictionaryExtensions
{
public sealed class <>E__0<TKey, TValue>
{
[PublicAPI]
public TValue? GetValueOrDefault(TKey key)
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static TValue? GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key)
{
if (!dict.TryGetValue(key, out var value))
{
return default(TValue);
}
return value;
}
}
public static class GameObjectExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public string? FullName()
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static string? FullName(this GameObject obj)
{
if (Object.op_Implicit((Object)(object)obj))
{
return obj.transform.FullName();
}
return null;
}
}
public static class ListExtensions
{
public sealed class <>E__0<T>
{
[PublicAPI]
public bool TryGetValue(int index, out T? value)
{
throw null;
}
[PublicAPI]
public T? GetValueOrDefault(int index)
{
throw null;
}
[PublicAPI]
public bool TrySetValue(int index, T value)
{
throw null;
}
}
public sealed class <>E__1<T>
{
[PublicAPI]
public bool TryGetValue(int index, out T? value)
{
throw null;
}
[PublicAPI]
public T? GetValueOrDefault(int index)
{
throw null;
}
[PublicAPI]
public bool TrySetValue(int index, T value)
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static bool TryGetValue<T>(this IList<T?>? list, int index, out T? value)
{
if (index < 0 || index >= list.Count)
{
value = default(T);
return false;
}
value = list[index];
return true;
}
[SpecialName]
[PublicAPI]
public static T? GetValueOrDefault<T>(this IList<T?>? list, int index)
{
if (!list.TryGetValue(index, out T value))
{
return default(T);
}
return value;
}
[SpecialName]
[PublicAPI]
public static bool TrySetValue<T>(this IList<T?>? list, int index, T? value)
{
if (index < 0 || index >= list.Count)
{
return false;
}
list[index] = value;
return true;
}
[SpecialName]
[PublicAPI]
public static bool TryGetValue<T>(this T?[]? array, int index, out T? value)
{
if (index < 0 || index >= array.Length)
{
value = default(T);
return false;
}
value = array[index];
return true;
}
[SpecialName]
[PublicAPI]
public static T? GetValueOrDefault<T>(this T?[]? array, int index)
{
if (!array.TryGetValue(index, out T value))
{
return default(T);
}
return value;
}
[SpecialName]
[PublicAPI]
public static bool TrySetValue<T>(this T?[]? array, int index, T? value)
{
if (index < 0 || index >= array.Length)
{
return false;
}
array[index] = value;
return true;
}
}
public static class MonoBehaviourExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public string? FullName()
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static string? FullName(this MonoBehaviour behaviour)
{
if (Object.op_Implicit((Object)(object)behaviour))
{
return ((Component)behaviour).transform.FullName();
}
return null;
}
}
public static class ObjectExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public T? MethodInvoke<T>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4, T5>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4, T5, T6>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7, T8>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7, T8, T9>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public void MethodInvoke(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public T? GetFieldValue<T>(string fieldName)
{
throw null;
}
[PublicAPI]
public void SetFieldValue<T>(string fieldName, T value)
{
throw null;
}
[PublicAPI]
public T? GetPropertyValue<T>(string propertyName)
{
throw null;
}
[PublicAPI]
public void SetPropertyValue<T>(string propertyName, T value)
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static T? MethodInvoke<T>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (methodInfo.IsGenericMethod)
{
throw new MethodAccessException("use object.GenericMethodInvoke instead.");
}
if (methodInfo.GetParameters().Length != parameters.Length)
{
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
object obj2 = methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
if (obj2 is T)
{
return (T)obj2;
}
return default(T);
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4, T5>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4, T5, T6>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7, T8>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7, T8, T9>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvoke<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static void MethodInvoke(this object obj, string methodName, params object?[] parameters)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (methodInfo.IsGenericMethod)
{
throw new MethodAccessException("use object.GenericMethodInvoke instead.");
}
if (methodInfo.GetParameters().Length != parameters.Length)
{
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
methodInfo.Invoke(methodInfo.IsStatic ? null : obj, parameters);
}
[SpecialName]
[PublicAPI]
public static T? GetFieldValue<T>(this object obj, string fieldName)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(fieldName))
{
throw new ArgumentNullException("fieldName");
}
FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), fieldName);
if (fieldInfo == null)
{
throw new FieldAccessException("Field " + fieldName + " not found.");
}
object value = fieldInfo.GetValue(fieldInfo.IsStatic ? null : obj);
if (value is T)
{
return (T)value;
}
return default(T);
}
[SpecialName]
[PublicAPI]
public static void SetFieldValue<T>(this object obj, string fieldName, T value)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(fieldName))
{
throw new ArgumentNullException("fieldName");
}
FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), fieldName);
if (fieldInfo == null)
{
throw new FieldAccessException("Field " + fieldName + " not found.");
}
fieldInfo.SetValue(fieldInfo.IsStatic ? null : obj, value);
}
[SpecialName]
[PublicAPI]
public static T? GetPropertyValue<T>(this object obj, string propertyName)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(propertyName))
{
throw new ArgumentNullException("propertyName");
}
PropertyInfo propertyInfo = AccessTools.Property(obj.GetType(), propertyName);
if (propertyInfo == null)
{
throw new MemberAccessException("Property " + propertyName + " not found.");
}
MethodInfo getMethod = propertyInfo.GetMethod;
if (getMethod == null)
{
throw new MethodAccessException("Property " + propertyName + " don't have any getter.");
}
object value = propertyInfo.GetValue(getMethod.IsStatic ? null : obj);
if (value is T)
{
return (T)value;
}
return default(T);
}
[SpecialName]
[PublicAPI]
public static void SetPropertyValue<T>(this object obj, string propertyName, T value)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (string.IsNullOrWhiteSpace(propertyName))
{
throw new ArgumentNullException("propertyName");
}
PropertyInfo propertyInfo = AccessTools.Property(obj.GetType(), propertyName);
if (propertyInfo == null)
{
throw new MemberAccessException("Property " + propertyName + " not found.");
}
MethodInfo setMethod = propertyInfo.SetMethod;
if (setMethod == null)
{
throw new MethodAccessException("Property " + propertyName + " don't have any setter.");
}
propertyInfo.SetValue(setMethod.IsStatic ? null : obj, value);
}
}
public static class StringExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public string? FirstPath(char value)
{
throw null;
}
[PublicAPI]
public string? FirstPath(string value)
{
throw null;
}
[PublicAPI]
public string? LastPath(char value)
{
throw null;
}
[PublicAPI]
public string? LastPath(string value)
{
throw null;
}
[PublicAPI]
public string? MiddlePath(char first, char last)
{
throw null;
}
[PublicAPI]
public string? MiddlePath(string first, string last)
{
throw null;
}
[PublicAPI]
public string? MiddlePath(char first, string last)
{
throw null;
}
[PublicAPI]
public string? MiddlePath(string first, char last)
{
throw null;
}
[PublicAPI]
public bool TryGetValue(int index, out char? value)
{
throw null;
}
[PublicAPI]
public char? GetValueOrDefault(int index)
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static string? FirstPath(this string str, char value)
{
int num = str.LastIndexOf(value);
if (num >= 0)
{
return str.Substring(0, num);
}
return null;
}
[SpecialName]
[PublicAPI]
public static string? FirstPath(this string str, string value)
{
int num = str.LastIndexOf(value, StringComparison.Ordinal);
if (num >= 0)
{
return str.Substring(0, num - value.Length + 1);
}
return null;
}
[SpecialName]
[PublicAPI]
public static string? LastPath(this string str, char value)
{
int num = str.IndexOf(value);
if (num >= 0)
{
return str.Substring(num + 1);
}
return null;
}
[SpecialName]
[PublicAPI]
public static string? LastPath(this string str, string value)
{
int num = str.IndexOf(value, StringComparison.Ordinal);
if (num >= 0)
{
return str.Substring(num + value.Length);
}
return null;
}
[SpecialName]
[PublicAPI]
public static string? MiddlePath(this string str, char first, char last)
{
return str.FirstPath(last)?.LastPath(first);
}
[SpecialName]
[PublicAPI]
public static string? MiddlePath(this string str, string first, string last)
{
return str.FirstPath(last)?.LastPath(first);
}
[SpecialName]
[PublicAPI]
public static string? MiddlePath(this string str, char first, string last)
{
return str.FirstPath(last)?.LastPath(first);
}
[SpecialName]
[PublicAPI]
public static string? MiddlePath(this string str, string first, char last)
{
return str.FirstPath(last)?.LastPath(first);
}
[SpecialName]
[PublicAPI]
public static bool TryGetValue(this string str, int index, out char? value)
{
if (index < 0 || index >= str.Length)
{
value = null;
return false;
}
value = str[index];
return true;
}
[SpecialName]
[PublicAPI]
public static char? GetValueOrDefault(this string str, int index)
{
if (!str.TryGetValue(index, out var value))
{
return null;
}
return value;
}
}
public static class TransformExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public string? FullName()
{
throw null;
}
[PublicAPI]
public Vector3 GetWorldScale()
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static string? FullName(this Transform transform)
{
string text = ((Object)transform).name;
while (Object.op_Implicit((Object)(object)transform.parent))
{
transform = transform.parent;
text = ((Object)transform).name + "/" + text;
}
return text;
}
[SpecialName]
[PublicAPI]
public static Vector3 GetWorldScale(this Transform transform)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = transform.localScale;
Transform parent = transform.parent;
while (Object.op_Implicit((Object)(object)parent))
{
val = Vector3.Scale(val, parent.localScale);
parent = parent.parent;
}
return val;
}
}
[PublicAPI]
public class TraverseEx<T>
{
private readonly Traverse<T> _traverse;
public T Value
{
get
{
return _traverse.Value;
}
set
{
_traverse.Value = value;
}
}
public T V
{
get
{
return _traverse.Value;
}
set
{
_traverse.Value = value;
}
}
public TraverseEx(Traverse<T> traverse)
{
_traverse = traverse;
base..ctor();
}
public void Set(T value)
{
_traverse.Value = value;
}
public T Get()
{
return _traverse.Value;
}
public static implicit operator T(TraverseEx<T> instance)
{
return instance._traverse.Value;
}
public static explicit operator TraverseEx<T>(Traverse<T> traverse)
{
return new TraverseEx<T>(traverse);
}
}
public static class TypeExtensions
{
public sealed class <>E__0
{
[PublicAPI]
public T? MethodInvokeInType<T>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4, T5>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7, T8>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7, T8, T9>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public void MethodInvokeInType(string methodName, params object?[] parameters)
{
throw null;
}
[PublicAPI]
public T? GetFieldValueInType<T>(string fieldName)
{
throw null;
}
[PublicAPI]
public void SetFieldValueInType<T>(string fieldName, T value)
{
throw null;
}
[PublicAPI]
public T? GetPropertyValueInType<T>(string propertyName)
{
throw null;
}
[PublicAPI]
public void SetPropertyValueInType<T>(string propertyName, T value)
{
throw null;
}
}
[SpecialName]
[PublicAPI]
public static T? MethodInvokeInType<T>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (methodInfo.IsGenericMethod)
{
throw new MethodAccessException("use Type.GenericMethodInvokeInType instead.");
}
if (methodInfo.GetParameters().Length != parameters.Length)
{
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
object obj = methodInfo.Invoke(null, parameters);
if (obj is T)
{
return (T)obj;
}
return default(T);
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4, T5>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7, T8>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7, T8, T9>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static object GenericMethodInvokeInType<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (!methodInfo.IsGenericMethod)
{
throw new MethodAccessException("Method " + methodName + " is not generic method.");
}
methodInfo = methodInfo.MakeGenericMethod(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10));
if (methodInfo.GetParameters().Length == parameters.Length)
{
return methodInfo.Invoke(null, parameters);
}
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
[SpecialName]
[PublicAPI]
public static void MethodInvokeInType(this Type type, string methodName, params object?[] parameters)
{
if (string.IsNullOrWhiteSpace(methodName))
{
throw new ArgumentNullException("methodName");
}
Type[] types = AccessTools.GetTypes(parameters);
MethodInfo methodInfo = AccessTools.Method(type, methodName, types, (Type[])null);
if (methodInfo == null)
{
methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
}
if (methodInfo == null)
{
throw new MethodAccessException("Method " + methodName + " with parameters [" + string.Join(", ", types.ToList()) + "] not found.");
}
if (methodInfo.IsGenericMethod)
{
throw new MethodAccessException("use Type.GenericMethodInvokeInType instead.");
}
if (methodInfo.GetParameters().Length != parameters.Length)
{
throw new TargetParameterCountException("Method " + methodName + " parameters count not match.");
}
methodInfo.Invoke(null, parameters);
}
[SpecialName]
[PublicAPI]
public static T? GetFieldValueInType<T>(this Type type, string fieldName)
{
if (string.IsNullOrWhiteSpace(fieldName))
{
throw new ArgumentNullException("fieldName");
}
FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
if (fieldInfo == null)
{
throw new FieldAccessException("Field " + fieldName + " not found.");
}
object value = fieldInfo.GetValue(null);
if (value is T)
{
return (T)value;
}
return default(T);
}
[SpecialName]
[PublicAPI]
public static void SetFieldValueInType<T>(this Type type, string fieldName, T value)
{
if (string.IsNullOrWhiteSpace(fieldName))
{
throw new ArgumentNullException("fieldName");
}
FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
if (fieldInfo == null)
{
throw new FieldAccessException("Field " + fieldName + " not found.");
}
fieldInfo.SetValue(null, value);
}
[SpecialName]
[PublicAPI]
public static T? GetPropertyValueInType<T>(this Type type, string propertyName)
{
if (string.IsNullOrWhiteSpace(propertyName))
{
throw new ArgumentNullException("propertyName");
}
PropertyInfo propertyInfo = AccessTools.Property(type, propertyName);
if (propertyInfo == null)
{
throw new MemberAccessException("Property " + propertyName + " not found.");
}
if (propertyInfo.GetMethod == null)
{
throw new MethodAccessException("Property " + propertyName + " don't have any getter.");
}
object value = propertyInfo.GetValue(null);
if (value is T)
{
return (T)value;
}
return default(T);
}
[SpecialName]
[PublicAPI]
public static void SetPropertyValueInType<T>(this Type type, string propertyName, T value)
{
if (string.IsNullOrWhiteSpace(propertyName))
{
throw new ArgumentNullException("propertyName");
}
PropertyInfo propertyInfo = AccessTools.Property(type, propertyName);
if (propertyInfo == null)
{
throw new MemberAccessException("Property " + propertyName + " not found.");
}
if (propertyInfo.SetMethod == null)
{
throw new MethodAccessException("Property " + propertyName + " don't have any setter.");
}
propertyInfo.SetValue(null, value);
}
}
}
namespace BepInExUtils.Commands
{
public readonly record struct CommandInfo
{
public readonly CommandManager.Command Command;
public readonly string Description;
public readonly string Name;
public CommandInfo(string Name, string Description, CommandManager.Command Command)
{
this.Command = Command;
this.Description = Description;
this.Name = Name;
}
[CompilerGenerated]
public void Deconstruct(out string Name, out string Description, out CommandManager.Command Command)
{
Name = this.Name;
Description = this.Description;
Command = this.Command;
}
}
[PublicAPI]
public sealed class CommandManager
{
public delegate Task Command(string[] args);
public static readonly CommandManager Instance = new CommandManager();
private readonly Dictionary<string, CommandInfo> _commands = new Dictionary<string, CommandInfo>();
private CommandManager()
{
AddDefaultCommands();
Utils.Logger.Debug("CommandManager init");
}
private void AddDefaultCommands()
{
AddCommand(new CommandInfo("help", "Show command infos", async delegate
{
IEnumerable<string> values = _commands.Values.Select((CommandInfo cmd) => cmd.Name + " - " + cmd.Description);
await Utils.Logger.InfoAsync("Available commands:\n" + string.Join("\n", values));
}));
AddCommand(new CommandInfo("echo", "Echo args", async delegate(string[] args)
{
await Utils.Logger.InfoAsync(string.Join("\n", args));
}));
}
public void AddCommand(CommandInfo commandInfo)
{
if (_commands.ContainsKey(commandInfo.Name))
{
Utils.Logger.Error("Command " + commandInfo.Name + " already exists");
}
else
{
_commands.Add(commandInfo.Name, commandInfo);
}
}
public void AddCommand(string commandName, string description, Command command)
{
AddCommand(new CommandInfo(commandName, description, command));
}
public async Task<bool> ExecuteCommand(string command, params string[] args)
{
if (!_commands.TryGetValue(command, out var value))
{
return false;
}
await value.Command(args);
return true;
}
}
}
namespace BepInExUtils.Attributes
{
[AttributeUsage(AttributeTargets.Class)]
[PublicAPI]
public class AccessExtensionsAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[PublicAPI]
public class AccessFieldAttribute<T> : Attribute
{
public string FieldName { get; protected set; }
public AccessFieldAttribute(string fieldName)
{
FieldName = fieldName;
base..ctor();
}
}
[AttributeUsage(AttributeTargets.Class)]
[PublicAPI]
public class AccessInstanceAttribute<T> : Attribute
{
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[PublicAPI]
public class AccessMethodAttribute : Attribute
{
public string MethodName { get; protected set; }
public Type[] Args { get; protected set; }
public AccessMethodAttribute(string methodName, params Type[] args)
{
MethodName = methodName;
Args = args;
base..ctor();
}
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[PublicAPI]
public class AccessMethodAttribute<T> : Attribute
{
public string MethodName { get; protected set; }
public Type[] Args { get; protected set; }
public AccessMethodAttribute(string methodName, params Type[] args)
{
MethodName = methodName;
Args = args;
base..ctor();
}
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[PublicAPI]
public class AccessPropertyAttribute<T> : Attribute
{
public string PropertyName { get; protected set; }
public AccessPropertyAttribute(string propertyName)
{
PropertyName = propertyName;
base..ctor();
}
}
[AttributeUsage(AttributeTargets.Class)]
[PublicAPI]
public class BepInUtilsAttribute : Attribute
{
public string Guid { get; protected set; }
public string Name { get; protected set; }
public string Version { get; protected set; }
public BepInUtilsAttribute(string guid, string name, string version)
{
Guid = guid;
Name = name;
Version = version;
base..ctor();
}
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[PublicAPI]
public class ConfigBindAttribute<T> : Attribute where T : IComparable
{
public string Key { get; protected set; }
public ConfigDefinition ConfigDefinition { get; protected set; }
public T DefaultValue { get; protected set; }
public ConfigDescription? ConfigDescription { get; protected set; }
public ConfigBindAttribute(string key, string section, T defaultValue, string description)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
Key = key;
ConfigDefinition = new ConfigDefinition(section, key);
DefaultValue = defaultValue;
ConfigDescription = new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>());
}
public ConfigBindAttribute(string key, string section, T defaultValue, string description, T minValue, T maxValue)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
Key = key;
ConfigDefinition = new ConfigDefinition(section, key);
DefaultValue = defaultValue;
ConfigDescription = new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<T>(minValue, maxValue), Array.Empty<object>());
}
}
}