Ejemplo n.º 1
0
        public TypeInformation(TypeDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;
            NamespaceChain       = def.Namespace.Split('.');

            foreach (var method in def.Methods)
            {
                var mtd = new MethodInformation(method, metadataContext);
                if (mtd.IsStaticConstructor)
                {
                    StaticConstructor = mtd;
                }
                Methods.Add(mtd);
            }
            foreach (var prop in def.Properties)
            {
                Properties.Add(new PropertyInformation(prop, metadataContext));
            }
            foreach (var field in def.Fields)
            {
                Fields.Add(new FieldInformation(field, metadataContext));
            }
            foreach (var nested in def.NestedTypes)
            {
                Nested.Add(new TypeInformation(nested, metadataContext));
            }


            this.genericParameterTypes = def.GenericParameters.Select(a => MetadataContext.GetTypeInformation(a)).ToArray();
            TypeAttributes             = def.Attributes.ToString().Split(sep, StringSplitOptions.RemoveEmptyEntries);
        }
Ejemplo n.º 2
0
        public MethodInformation(MethodDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            if (def.HasBody)
            {
                foreach (var Inst in def.Body.Instructions)
                {
                    Instructions.Add(new InstructionInformation(Inst));
                }
                if (def.Body.HasVariables)
                {
                    foreach (var localVar in def.Body.Variables)
                    {
                        LocalVariables.Add(new VariableInformation(localVar, metadataContext));
                    }
                }
            }
            if (def.HasParameters)
            {
                foreach (ParameterDefinition param in def.Parameters)
                {
                    Parameters.Add(new ParameterInformation(param, metadataContext));
                }
            }
            if (def.HasGenericParameters)
            {
                genericParameterTypes = def.GenericParameters.Select(a => MetadataContext.GetTypeInformation(a)).ToArray();
            }
        }
Ejemplo n.º 3
0
        public TypeInformation(ArrayType def, MetadataContext metadataContext)
        {
            this.definitionArray = def;
            this.MetadataContext = metadataContext;
            var dd = definitionArray.ElementType;

            this.elementType = IsArray ? MetadataContext.GetTypeInformation(dd) : null;
        }
Ejemplo n.º 4
0
 public void SetupBaseAndInterface(MetadataContext metadataContext)
 {
     if (definition == null || IsGenericInstance)
     {
         return;
     }
     foreach (var Interface in definition.Interfaces)
     {
         Interfaces.Add(MetadataContext.GetTypeInformation(Interface.InterfaceType));
     }
     if (definition.BaseType != null)
     {
         BaseType = MetadataContext.GetTypeInformation(definition.BaseType);
     }
 }
Ejemplo n.º 5
0
        public static MethodInformation GetMetaInformation(
            this MethodReference methodReference, MetadataContext context)
        {
            var type = context.GetTypeInformation(methodReference.DeclaringType);

            foreach (var mtdInfo in type.Methods)
            {
                if (mtdInfo.Definition is MethodReference mtdRef)
                {
                    if (mtdRef.Name == methodReference.Name)
                    {
                        return(mtdInfo);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
        public TypeInformation(GenericInstanceType def, MetadataContext metadataContext)
        {
            reference            = def;
            this.definitionGI    = def;
            this.MetadataContext = metadataContext;
            var ElementType = metadataContext.GetTypeInformation(def.ElementType);

            this.genericElementType   = ElementType;
            this.genericArgumentTypes = def.GenericArguments.Select(a => MetadataContext.GetTypeInformation(a)).ToArray();
            this.definition           = ElementType.definition;
            Methods           = ElementType.Methods;
            StaticConstructor = ElementType.StaticConstructor;
            Properties        = ElementType.Properties;
            Fields            = ElementType.Fields;
            Nested            = ElementType.Nested;
            TypeAttributes    = ElementType.TypeAttributes;
        }