public void Map(Type accessor, Type map, List <Injector> injectors) { var cur = map; while (cur != null && cur != typeof(object)) { foreach (var method in cur.GetMethods()) { var attr = method.GetCustomAttribute <ProxyMap>(); if (attr != null) { var desc = InjectorMetaData.FilterTags(injectors, attr.Desc); var name = InjectorMetaData.NameOfMethod(accessor, injectors, attr.Name, desc); if (name == null) { Logging.Logs("[{0}] Failed to find obfuscated name to map", GetType().Name); Logging.Logs("\t{0} {1} {2} {3}", accessor.Name, attr.Name, desc, method.Name); continue; } MapCall(name, desc, method); } } cur = cur.BaseType; } }
public static AType ProxyAccessor <AType, DType>(DType @delegate, params object[] constructor) { var type = InjectorMetaData.AccessorToGameType <AType>(Injectors, Assembly); var factory = CreateFactory <AType, DType>(); var generator = new ProxyGenerator(); return((AType)generator.CreateClassProxy(type, constructor, factory.CreateInterceptor(@delegate))); }
public static object Wrap(object o) { if (o == null) { return(null); } var cur = o.GetType(); while (cur != null && cur != typeof(object)) { Type type; CachedAccessorWrapperTypes.TryGetValue(cur, out type); if (type == null) { var name = InjectorMetaData.TypeToSimpleName(Injectors, cur); if (name != null) { type = WrapperForSimpleName(name); } } if (type != null) { var instance = Activator.CreateInstance(type); var wrapper = instance as Wrapper.Wrapper; if (wrapper != null) { wrapper.Underlying = o; } var swrapper = instance as StaticContextWrapper; if (swrapper != null) { swrapper.Parent = WrappedGame; } if (!CachedAccessorWrapperTypes.ContainsKey(cur)) { CachedAccessorWrapperTypes.Add(cur, type); } return(instance); } cur = cur.BaseType; } return(o); }
public static bool IsSubclass(object o, string name) { var t = InjectorMetaData.TypeForSimpleName(Injectors, name); return(t.IsInstanceOfType(o)); }