コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
ファイル: StaticGameContext.cs プロジェクト: sharkman/Storm
        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);
        }
コード例 #4
0
ファイル: StaticGameContext.cs プロジェクト: sharkman/Storm
        public static bool IsSubclass(object o, string name)
        {
            var t = InjectorMetaData.TypeForSimpleName(Injectors, name);

            return(t.IsInstanceOfType(o));
        }