Exemplo n.º 1
0
        static bool TryGetDefinition(ModuleDefinition module, Type type_info, out TypeReference type)
        {
            type = null;
            if (!TryCurrentModule(module, type_info))
            {
                return(false);
            }

            var typedef = module.GetType(type_info.type_fullname);

            if (typedef == null)
            {
                return(false);
            }

            var nested_names = type_info.nested_names;

            if (!Mixin.IsNullOrEmpty(nested_names))
            {
                for (int i = 0; i < nested_names.Length; i++)
                {
                    typedef = Mixin.GetNestedType(typedef, nested_names[i]);
                }
            }

            type = typedef;
            return(true);
        }
Exemplo n.º 2
0
        static TypeDefinition GetTypeDefinition(ModuleDefinition module, TypeReference type)
        {
            if (!type.IsNested)
            {
                return(module.GetType(type.Namespace, type.Name));
            }

            var declaring_type = type.DeclaringType.Resolve();

            if (declaring_type == null)
            {
                return(null);
            }

            return(Mixin.GetNestedType(declaring_type, type.Name));
        }
Exemplo n.º 3
0
        TypeDefinition GetNestedType(string fullname)
        {
            var names = fullname.Split('/');
            var type  = GetType(names[0]);

            if (type == null)
            {
                return(null);
            }

            for (int i = 1; i < names.Length; i++)
            {
                var nested_type = Mixin.GetNestedType(type, names[i]);
                if (nested_type == null)
                {
                    return(null);
                }

                type = nested_type;
            }

            return(type);
        }