Пример #1
0
 internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
 {
     if (PseudoCustomAttribute.IsDefined(field, caType))
     {
         return(true);
     }
     return(CustomAttribute.IsCustomAttributeDefined(field.GetRuntimeModule(), field.MetadataToken, caType));
 }
 internal static Attribute GetCustomAttribute(RuntimeFieldInfo field)
 {
     int num;
     if ((field.DeclaringType != null) && field.GetRuntimeModule().MetadataImport.GetFieldOffset(field.DeclaringType.MetadataToken, field.MetadataToken, out num))
     {
         return new FieldOffsetAttribute(num);
     }
     return null;
 }
Пример #3
0
        internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
        {
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(field, caType, out count);
            object[]    customAttributes2 = CustomAttribute.GetCustomAttributes(field.GetRuntimeModule(), field.MetadataToken, count, caType, !CustomAttribute.AllowCriticalCustomAttributes(field));
            if (count > 0)
            {
                Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
            }
            return(customAttributes2);
        }
        internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
        {
            int num = 0;

            Attribute[] customAttributes  = PseudoCustomAttribute.GetCustomAttributes(field, caType, out num);
            object[]    customAttributes2 = CustomAttribute.GetCustomAttributes(field.GetRuntimeModule(), field.MetadataToken, num, caType, !CustomAttribute.AllowCriticalCustomAttributes(field));
            if (num > 0)
            {
                Array.Copy(customAttributes, 0, customAttributes2, customAttributes2.Length - num, num);
            }
            return(customAttributes2);
        }
        internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
        {
            int count = 0;

            Attribute[] sourceArray      = PseudoCustomAttribute.GetCustomAttributes(field, caType, out count);
            object[]    destinationArray = GetCustomAttributes(field.GetRuntimeModule(), field.MetadataToken, count, caType, !AllowCriticalCustomAttributes(field));
            if (count > 0)
            {
                Array.Copy(sourceArray, 0, destinationArray, destinationArray.Length - count, count);
            }
            return(destinationArray);
        }
Пример #6
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeFieldInfo target)
        {
            IList <CustomAttributeData> customAttributes = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);
            int count = 0;

            Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, out count);
            if (count == 0)
            {
                return(customAttributes);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + count];
            customAttributes.CopyTo(array, count);
            for (int i = 0; i < count; i++)
            {
                array[i] = new CustomAttributeData(attributeArray[i]);
            }
            return(Array.AsReadOnly <CustomAttributeData>(array));
        }
Пример #7
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static Attribute GetCustomAttribute(RuntimeFieldInfo field)
 {
     return GetCustomAttribute(field.MetadataToken, field.GetRuntimeModule()); ;
 }
Пример #8
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeFieldInfo target)
        {
            Contract.Assert(target != null);

            IList<CustomAttributeData> cad = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);

            int pcaCount = 0;
            Attribute[] a = PseudoCustomAttribute.GetCustomAttributes((RuntimeFieldInfo)target, typeof(object) as RuntimeType, out pcaCount);

            if (pcaCount == 0)
                return cad;

            CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount];
            cad.CopyTo(pca, pcaCount);
            for (int i = 0; i < pcaCount; i++)
            {
                pca[i] = new CustomAttributeData(a[i]);
            }

            return Array.AsReadOnly(pca);
        }
Пример #9
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static Object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
        {
            Contract.Requires(field != null);
            Contract.Requires(caType != null);

            int pcaCount = 0;
            Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(field, caType, out pcaCount);
            object[] attributes = GetCustomAttributes(field.GetRuntimeModule(), field.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(field));
            if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount);
            return attributes;
        }
Пример #10
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
        {
            Contract.Requires(field != null);
            Contract.Requires(caType != null);

            if (PseudoCustomAttribute.IsDefined(field, caType))
                return true;

            return IsCustomAttributeDefined(field.GetRuntimeModule(), field.MetadataToken, caType);
        }
Пример #11
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeFieldInfo target)
        {
            IList <CustomAttributeData> customAttributes = CustomAttributeData.GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);
            int num = 0;

            Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, out num);
            if (num == 0)
            {
                return(customAttributes);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + num];
            customAttributes.CopyTo(array, num);
            for (int i = 0; i < num; i++)
            {
                array[i] = new CustomAttributeData(customAttributes2[i]);
            }
            return(Array.AsReadOnly <CustomAttributeData>(array));
        }
Пример #12
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeFieldInfo target)
        {
            IList <CustomAttributeData> customAttributes1 = CustomAttributeData.GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);
            int count = 0;

            Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, out count);
            if (count == 0)
            {
                return(customAttributes1);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes1.Count + count];
            customAttributes1.CopyTo(array, count);
            for (int index = 0; index < count; ++index)
            {
                array[index] = new CustomAttributeData(customAttributes2[index]);
            }
            return((IList <CustomAttributeData>)Array.AsReadOnly <CustomAttributeData>(array));
        }
 internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
 {
     return (PseudoCustomAttribute.IsDefined(field, caType) || IsCustomAttributeDefined(field.GetRuntimeModule(), field.MetadataToken, caType));
 }
Пример #14
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static Attribute GetCustomAttribute(RuntimeFieldInfo field)
        {
            int fieldOffset;

            if (field.DeclaringType != null &&
#if MONO
                (fieldOffset = field.GetFieldOffset ()) >= 0)
#else
                field.GetRuntimeModule().MetadataImport.GetFieldOffset(field.DeclaringType.MetadataToken, field.MetadataToken, out fieldOffset))
#endif
                return new FieldOffsetAttribute(fieldOffset);

            return null;
        }
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
        {
            Contract.Requires(field != null);
            Contract.Requires(caType != null);

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && caType != null)
            {
                FrameworkEventSource.Log.QueryAttributeIsDefined(caType.GetFullNameForEtw());
            }
#endif

            if (PseudoCustomAttribute.IsDefined(field, caType))
                return true;

            return IsCustomAttributeDefined(field.GetRuntimeModule(), field.MetadataToken, caType);
        }
 internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeFieldInfo target)
 {
     IList<CustomAttributeData> customAttributes = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);
     int count = 0;
     Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, out count);
     if (count == 0)
     {
         return customAttributes;
     }
     CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + count];
     customAttributes.CopyTo(array, count);
     for (int i = 0; i < count; i++)
     {
         array[i] = new CustomAttributeData(attributeArray[i]);
     }
     return Array.AsReadOnly<CustomAttributeData>(array);
 }
 internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
 {
     int count = 0;
     Attribute[] sourceArray = PseudoCustomAttribute.GetCustomAttributes(field, caType, out count);
     object[] destinationArray = GetCustomAttributes(field.GetRuntimeModule(), field.MetadataToken, count, caType, !AllowCriticalCustomAttributes(field));
     if (count > 0)
     {
         Array.Copy(sourceArray, 0, destinationArray, destinationArray.Length - count, count);
     }
     return destinationArray;
 }