当前位置: 首页>>代码示例>>C#>>正文


C# RuntimeType.GetRuntimeModule方法代码示例

本文整理汇总了C#中RuntimeType.GetRuntimeModule方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeType.GetRuntimeModule方法的具体用法?C# RuntimeType.GetRuntimeModule怎么用?C# RuntimeType.GetRuntimeModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RuntimeType的用法示例。


在下文中一共展示了RuntimeType.GetRuntimeModule方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RuntimePropertyInfo

 internal unsafe RuntimePropertyInfo(int tkProperty, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
 {
     RuntimeMethodInfo info;
     MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport;
     this.m_token = tkProperty;
     this.m_reflectedTypeCache = reflectedTypeCache;
     this.m_declaringType = declaredType;
     metadataImport.GetPropertyProps(tkProperty, out this.m_utf8name, out this.m_flags, out MetadataArgs.Skip.ConstArray);
     int associatesCount = metadataImport.GetAssociatesCount(tkProperty);
     AssociateRecord* result = (AssociateRecord*) stackalloc byte[(((IntPtr) associatesCount) * sizeof(AssociateRecord))];
     metadataImport.GetAssociates(tkProperty, result, associatesCount);
     Associates.AssignAssociates(result, associatesCount, declaredType, reflectedTypeCache.RuntimeType, out info, out info, out info, out this.m_getterMethod, out this.m_setterMethod, out this.m_otherMethod, out isPrivate, out this.m_bindingFlags);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:RuntimePropertyInfo.cs

示例2: RuntimeEventInfo

 internal unsafe RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
 {
     RuntimeMethodInfo info;
     MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport;
     this.m_token = tkEvent;
     this.m_reflectedTypeCache = reflectedTypeCache;
     this.m_declaringType = declaredType;
     RuntimeType runtimeType = reflectedTypeCache.RuntimeType;
     metadataImport.GetEventProps(tkEvent, out this.m_utf8name, out this.m_flags);
     int associatesCount = metadataImport.GetAssociatesCount(tkEvent);
     AssociateRecord* result = (AssociateRecord*) stackalloc byte[(((IntPtr) associatesCount) * sizeof(AssociateRecord))];
     metadataImport.GetAssociates(tkEvent, result, associatesCount);
     Associates.AssignAssociates(result, associatesCount, declaredType, runtimeType, out this.m_addMethod, out this.m_removeMethod, out this.m_raiseMethod, out info, out info, out this.m_otherMethod, out isPrivate, out this.m_bindingFlags);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:RuntimeEventInfo.cs

示例3: GetCustomAttributesInternal

        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeType target)
        {
            Contract.Assert(target != null);

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

            int pcaCount = 0;
            Attribute[] a = PseudoCustomAttribute.GetCustomAttributes((RuntimeType)target, typeof(object) as RuntimeType, true, 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);
        }
开发者ID:enavro,项目名称:coreclr,代码行数:22,代码来源:CustomAttribute.cs

示例4: GetCustomAttributesInternal

 internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeType target)
 {
     IList<CustomAttributeData> customAttributes = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);
     int count = 0;
     Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, true, 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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:CustomAttributeData.cs

示例5: GetCustomAttribute

        [System.Security.SecurityCritical]  // auto-generated
        internal static StructLayoutAttribute GetCustomAttribute(RuntimeType type)
        {
            if (!IsDefined(type))
                return null;

            int pack = 0, size = 0;
            LayoutKind layoutKind = LayoutKind.Auto;
            switch (type.Attributes & TypeAttributes.LayoutMask)
            {
                case TypeAttributes.ExplicitLayout: layoutKind = LayoutKind.Explicit; break;
                case TypeAttributes.AutoLayout: layoutKind = LayoutKind.Auto; break;
                case TypeAttributes.SequentialLayout: layoutKind = LayoutKind.Sequential; break;
                default: Contract.Assume(false); break;
            }

            CharSet charSet = CharSet.None;
            switch (type.Attributes & TypeAttributes.StringFormatMask)
            {
                case TypeAttributes.AnsiClass: charSet = CharSet.Ansi; break;
                case TypeAttributes.AutoClass: charSet = CharSet.Auto; break;
                case TypeAttributes.UnicodeClass: charSet = CharSet.Unicode; break;
                default: Contract.Assume(false); break;
            }

#if MONO
            type.GetPacking (out pack, out size);
#else
            type.GetRuntimeModule().MetadataImport.GetClassLayout(type.MetadataToken, out pack, out size);
#endif

            // Metadata parameter checking should not have allowed 0 for packing size.
            // The runtime later converts a packing size of 0 to 8 so do the same here
            // because it's more useful from a user perspective. 
            if (pack == 0)
                pack = DEFAULT_PACKING_SIZE;

            return new StructLayoutAttribute(layoutKind, pack, size, charSet);
        }
开发者ID:razzfazz,项目名称:mono,代码行数:39,代码来源:attributes.cs

示例6: GetAttributeUsage

        [System.Security.SecurityCritical]  // auto-generated
        internal static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)
        {
            RuntimeModule decoratedModule = decoratedAttribute.GetRuntimeModule();
            MetadataImport scope = decoratedModule.MetadataImport;
            CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedAttribute.MetadataToken);

            AttributeUsageAttribute attributeUsageAttribute = null;

            for (int i = 0; i < car.Length; i++)
            {
                CustomAttributeRecord caRecord = car[i];
                RuntimeType attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;

                if (attributeType != (RuntimeType)typeof(AttributeUsageAttribute))
                    continue;

                if (attributeUsageAttribute != null)
                    throw new FormatException(String.Format(
                        CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), attributeType));

                AttributeTargets targets;
                bool inherited, allowMultiple;
                ParseAttributeUsageAttribute(caRecord.blob, out targets, out inherited, out allowMultiple);
                attributeUsageAttribute = new AttributeUsageAttribute(targets, allowMultiple, inherited);
            }

            if (attributeUsageAttribute == null)
                return AttributeUsageAttribute.Default;

            return attributeUsageAttribute;
        }
开发者ID:enavro,项目名称:coreclr,代码行数:32,代码来源:CustomAttribute.cs

示例7: GetCustomAttributes

        [System.Security.SecurityCritical]  // auto-generated
        internal static Object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
        {
            Contract.Requires(type != null);
            Contract.Requires(caType != null);

            if (type.GetElementType() != null) 
                return (caType.IsValueType) ? EmptyArray<Object>.Value : CreateAttributeArrayHelper(caType, 0);

            if (type.IsGenericType && !type.IsGenericTypeDefinition)
                type = type.GetGenericTypeDefinition() as RuntimeType;

            int pcaCount = 0;
            Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(type, caType, true, out pcaCount);

            // if we are asked to go up the hierarchy chain we have to do it now and regardless of the
            // attribute usage for the specific attribute because a derived attribute may override the usage...           
            // ... however if the attribute is sealed we can rely on the attribute usage
            if (!inherit || (caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited))
            {
                object[] attributes = GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(type));
                if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount);
                return attributes;
            }

            List<object> result = new List<object>();
            bool mustBeInheritable = false;
            bool useObjectArray = (caType == null || caType.IsValueType || caType.ContainsGenericParameters);
            Type arrayType = useObjectArray ? typeof(object) : caType;

            while (pcaCount > 0)
                result.Add(pca[--pcaCount]);

            while (type != (RuntimeType)typeof(object) && type != null)
            {
                object[] attributes = GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, 0, caType, mustBeInheritable, result, !AllowCriticalCustomAttributes(type));
                mustBeInheritable = true;
                for (int i = 0; i < attributes.Length; i++)
                    result.Add(attributes[i]);

                type = type.BaseType as RuntimeType;
            }

            object[] typedResult = CreateAttributeArrayHelper(arrayType, result.Count);
            Array.Copy(result.ToArray(), 0, typedResult, 0, result.Count);
            return typedResult;
        }
开发者ID:enavro,项目名称:coreclr,代码行数:47,代码来源:CustomAttribute.cs

示例8: IsDefined

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

            if (type.GetElementType() != null) 
                return false;

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

            if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType))
                return true;

            if (!inherit)
                return false;

            type = type.BaseType as RuntimeType;

            while (type != null)
            {
                if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType, 0, inherit))
                    return true;

                type = type.BaseType as RuntimeType;
            }

            return false;
        }
开发者ID:enavro,项目名称:coreclr,代码行数:29,代码来源:CustomAttribute.cs

示例9: RuntimeEventInfo

        [System.Security.SecurityCritical]  // auto-generated
        internal RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            Contract.Requires(declaredType != null);
            Contract.Requires(reflectedTypeCache != null);
            Contract.Assert(!reflectedTypeCache.IsGlobal);

            MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;

            m_token = tkEvent;
            m_reflectedTypeCache = reflectedTypeCache;        
            m_declaringType = declaredType;
            

            RuntimeType reflectedType = reflectedTypeCache.GetRuntimeType();

            scope.GetEventProps(tkEvent, out m_utf8name, out m_flags);

            RuntimeMethodInfo dummy;
            Associates.AssignAssociates(scope, tkEvent, declaredType, reflectedType, 
                out m_addMethod, out m_removeMethod, out m_raiseMethod, 
                out dummy, out dummy, out m_otherMethod, out isPrivate, out m_bindingFlags);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:23,代码来源:eventinfo.cs

示例10: RuntimePropertyInfo

        [System.Security.SecurityCritical]  // auto-generated
        internal RuntimePropertyInfo(
            int tkProperty, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            Contract.Requires(declaredType != null);
            Contract.Requires(reflectedTypeCache != null);
            Contract.Assert(!reflectedTypeCache.IsGlobal);

            MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;

            m_token = tkProperty;
            m_reflectedTypeCache = reflectedTypeCache;    
            m_declaringType = declaredType;

            ConstArray sig;
            scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out sig);

            RuntimeMethodInfo dummy;
            Associates.AssignAssociates(scope, tkProperty, declaredType, reflectedTypeCache.GetRuntimeType(), 
                out dummy, out dummy, out dummy,
                out m_getterMethod, out m_setterMethod, out m_otherMethod,
                out isPrivate, out m_bindingFlags);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:23,代码来源:propertyinfo.cs

示例11: RuntimePropertyInfo

        [System.Security.SecurityCritical]  // auto-generated 
        internal RuntimePropertyInfo( 
            int tkProperty, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        { 
            Contract.Requires(declaredType != null);
            Contract.Requires(reflectedTypeCache != null);
            Contract.Assert(!reflectedTypeCache.IsGlobal);
 
            MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;
 
            m_token = tkProperty; 
            m_reflectedTypeCache = reflectedTypeCache;
            m_declaringType = declaredType; 

            RuntimeMethodInfo dummy;

            scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out MetadataArgs.Skip.ConstArray); 
            int cAssociateRecord = scope.GetAssociatesCount(tkProperty);
            AssociateRecord* associateRecord = stackalloc AssociateRecord[cAssociateRecord]; 
            scope.GetAssociates(tkProperty, associateRecord, cAssociateRecord); 
            Associates.AssignAssociates(associateRecord, cAssociateRecord, declaredType, reflectedTypeCache.RuntimeType,
                out dummy, out dummy, out dummy, 
                out m_getterMethod, out m_setterMethod, out m_otherMethod,
                out isPrivate, out m_bindingFlags);
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:25,代码来源:XXXInfos.cs

示例12: IsDefined

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

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

            if (type.GetElementType() != null) 
                return false;

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

            if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType))
                return true;

            if (!inherit)
                return false;

            type = type.BaseType as RuntimeType;

            while (type != null)
            {
                if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType, 0, inherit))
                    return true;

                type = type.BaseType as RuntimeType;
            }

            return false;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:36,代码来源:CustomAttribute.cs

示例13: GetCustomAttributes

 internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
 {
     if (type.GetElementType() != null)
     {
         if (!caType.IsValueType)
         {
             return CreateAttributeArrayHelper(caType, 0);
         }
         return new object[0];
     }
     if (type.IsGenericType && !type.IsGenericTypeDefinition)
     {
         type = type.GetGenericTypeDefinition() as RuntimeType;
     }
     int count = 0;
     Attribute[] sourceArray = PseudoCustomAttribute.GetCustomAttributes(type, caType, true, out count);
     if (!inherit || (caType.IsSealed && !GetAttributeUsage(caType).Inherited))
     {
         object[] objArray = GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, count, caType, !AllowCriticalCustomAttributes(type));
         if (count > 0)
         {
             Array.Copy(sourceArray, 0, objArray, objArray.Length - count, count);
         }
         return objArray;
     }
     List<object> derivedAttributes = new List<object>();
     bool mustBeInheritable = false;
     Type elementType = (((caType == null) || caType.IsValueType) || caType.ContainsGenericParameters) ? typeof(object) : caType;
     while (count > 0)
     {
         derivedAttributes.Add(sourceArray[--count]);
     }
     while ((type != ((RuntimeType) typeof(object))) && (type != null))
     {
         object[] objArray2 = GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, 0, caType, mustBeInheritable, derivedAttributes, !AllowCriticalCustomAttributes(type));
         mustBeInheritable = true;
         for (int i = 0; i < objArray2.Length; i++)
         {
             derivedAttributes.Add(objArray2[i]);
         }
         type = type.BaseType as RuntimeType;
     }
     object[] destinationArray = CreateAttributeArrayHelper(elementType, derivedAttributes.Count);
     Array.Copy(derivedAttributes.ToArray(), 0, destinationArray, 0, derivedAttributes.Count);
     return destinationArray;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:CustomAttribute.cs

示例14: GetAttributeUsage

 internal static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)
 {
     RuntimeModule runtimeModule = decoratedAttribute.GetRuntimeModule();
     MetadataImport metadataImport = runtimeModule.MetadataImport;
     CustomAttributeRecord[] customAttributeRecords = CustomAttributeData.GetCustomAttributeRecords(runtimeModule, decoratedAttribute.MetadataToken);
     AttributeUsageAttribute attribute = null;
     for (int i = 0; i < customAttributeRecords.Length; i++)
     {
         CustomAttributeRecord record = customAttributeRecords[i];
         RuntimeType type = runtimeModule.ResolveType(metadataImport.GetParentToken((int) record.tkCtor), null, null) as RuntimeType;
         if (type == ((RuntimeType) typeof(AttributeUsageAttribute)))
         {
             AttributeTargets targets;
             bool flag;
             bool flag2;
             if (attribute != null)
             {
                 throw new FormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), new object[] { type }));
             }
             ParseAttributeUsageAttribute(record.blob, out targets, out flag, out flag2);
             attribute = new AttributeUsageAttribute(targets, flag2, flag);
         }
     }
     if (attribute == null)
     {
         return AttributeUsageAttribute.Default;
     }
     return attribute;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:CustomAttribute.cs


注:本文中的RuntimeType.GetRuntimeModule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。