Ejemplo n.º 1
0
        public static IList <CustomAttributeData> __GetCustomAttributes(ParameterInfo parameter, Type attributeType, bool inherit)
        {
            Module module = parameter.Module;
            List <CustomAttributeData> list = null;

            if (module.universe.ReturnPseudoCustomAttributes)
            {
                if (attributeType == null || attributeType.IsAssignableFrom(parameter.Module.universe.System_Runtime_InteropServices_MarshalAsAttribute))
                {
                    FieldMarshal spec;
                    if (parameter.__TryGetFieldMarshal(out spec))
                    {
                        if (list == null)
                        {
                            list = new List <CustomAttributeData>();
                        }
                        list.Add(CustomAttributeData.CreateMarshalAsPseudoCustomAttribute(parameter.Module, spec));
                    }
                }
            }
            ModuleBuilder mb    = module as ModuleBuilder;
            int           token = parameter.MetadataToken;

            if (mb != null && mb.IsSaved && mb.IsPseudoToken(token))
            {
                token = mb.ResolvePseudoToken(token);
            }
            return(GetCustomAttributesImpl(list, module, token, attributeType) ?? EmptyList);
        }
Ejemplo n.º 2
0
        internal sealed override List <CustomAttributeData> GetPseudoCustomAttributes(Type attributeType)
        {
            Module module = this.Module;
            List <CustomAttributeData> list = new List <CustomAttributeData>();

            if (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_MarshalAsAttribute))
            {
                FieldMarshal spec;
                if (__TryGetFieldMarshal(out spec))
                {
                    list.Add(CustomAttributeData.CreateMarshalAsPseudoCustomAttribute(module, spec));
                }
            }
            if (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_FieldOffsetAttribute))
            {
                int offset;
                if (__TryGetFieldOffset(out offset))
                {
                    list.Add(CustomAttributeData.CreateFieldOffsetPseudoCustomAttribute(module, offset));
                }
            }
            return(list);
        }