示例#1
0
        internal override IList <CustomAttributeData> GetCustomAttributesData(Type attributeType)
        {
            List <CustomAttributeData> list = module.GetCustomAttributes(this.MetadataToken, attributeType);

            if ((this.Attributes & FieldAttributes.HasFieldMarshal) != 0 &&
                (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_MarshalAsAttribute)))
            {
                list.Add(MarshalSpec.GetMarshalAsAttribute(module, this.MetadataToken));
            }
            if (declaringType.IsExplicitLayout &&
                (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_FieldOffsetAttribute)))
            {
                int rid = index + 1;
                // TODO use binary search?
                for (int i = 0; i < module.FieldLayout.records.Length; i++)
                {
                    if (module.FieldLayout.records[i].Field == rid)
                    {
                        ConstructorInfo constructor = module.universe.System_Runtime_InteropServices_FieldOffsetAttribute.GetConstructor(new Type[] { module.universe.System_Int32 });
                        list.Add(new CustomAttributeData(constructor,
                                                         new object[] { module.FieldLayout.records[i].Offset },
                                                         null));
                        break;
                    }
                }
            }
            return(list);
        }
示例#2
0
        internal override IList <CustomAttributeData> GetCustomAttributesData(Type attributeType)
        {
            IList <CustomAttributeData> list = base.GetCustomAttributesData(attributeType);

            if ((this.Attributes & ParameterAttributes.HasFieldMarshal) != 0 &&
                (attributeType == null || attributeType.IsAssignableFrom(this.Module.universe.System_Runtime_InteropServices_MarshalAsAttribute)))
            {
                list.Add(MarshalSpec.GetMarshalAsAttribute(this.Module, this.MetadataToken));
            }
            return(list);
        }
示例#3
0
文件: Field.cs 项目: pking1983/mono
        internal override IList <CustomAttributeData> GetCustomAttributesData(Type attributeType)
        {
            List <CustomAttributeData> list = module.GetCustomAttributes(this.MetadataToken, attributeType);

            if ((this.Attributes & FieldAttributes.HasFieldMarshal) != 0 &&
                (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_MarshalAsAttribute)))
            {
                list.Add(MarshalSpec.GetMarshalAsAttribute(module, this.MetadataToken));
            }
            if (declaringType.IsExplicitLayout &&
                (attributeType == null || attributeType.IsAssignableFrom(module.universe.System_Runtime_InteropServices_FieldOffsetAttribute)))
            {
                foreach (int i in module.FieldLayout.Filter(index + 1))
                {
                    ConstructorInfo constructor = module.universe.System_Runtime_InteropServices_FieldOffsetAttribute.GetPseudoCustomAttributeConstructor(module.universe.System_Int32);
                    list.Add(new CustomAttributeData(module, constructor,
                                                     new object[] { module.FieldLayout.records[i].Offset },
                                                     null));
                    break;
                }
            }
            return(list);
        }