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


C# RuntimeType.GetElementType方法代码示例

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


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

示例1: AddElementTypes

        internal static RuntimeType AddElementTypes(SerializationInfo info, RuntimeType type)
        {
            List<int> elementTypes = new List<int>();
            while(type.HasElementType)
            {
                if (type.IsSzArray)
                {
                    elementTypes.Add(SzArray);
                }
                else if (type.IsArray)
                {
                    elementTypes.Add(type.GetArrayRank());
                    elementTypes.Add(Array);
                }
                else if (type.IsPointer)
                {
                    elementTypes.Add(Pointer);
                }
                else if (type.IsByRef)
                {
                    elementTypes.Add(ByRef);
                }
                
                type = (RuntimeType)type.GetElementType();
            }

            info.AddValue("ElementTypes", elementTypes.ToArray(), typeof(int[]));

            return type;
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:30,代码来源:UnitySerializationHolder.cs

示例2: AddElementTypes

		internal static RuntimeType AddElementTypes(SerializationInfo info, RuntimeType type)
		{
			List<int> list = new List<int>();
			while (type.HasElementType)
			{
				if (type.IsSzArray)
				{
					list.Add(3);
				}
				else
				{
					if (type.IsArray)
					{
						list.Add(type.GetArrayRank());
						list.Add(2);
					}
					else
					{
						if (type.IsPointer)
						{
							list.Add(1);
						}
						else
						{
							if (type.IsByRef)
							{
								list.Add(4);
							}
						}
					}
				}
				type = (RuntimeType)type.GetElementType();
			}
			info.AddValue("ElementTypes", list.ToArray(), typeof(int[]));
			return type;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:36,代码来源:UnitySerializationHolder.cs

示例3: InitCustomAttributeType

 private static CustomAttributeType InitCustomAttributeType(RuntimeType parameterType)
 {
     CustomAttributeEncoding encodedType = TypeToCustomAttributeEncoding(parameterType);
     CustomAttributeEncoding undefined = CustomAttributeEncoding.Undefined;
     CustomAttributeEncoding encodedEnumType = CustomAttributeEncoding.Undefined;
     string enumName = null;
     if (encodedType == CustomAttributeEncoding.Array)
     {
         parameterType = (RuntimeType) parameterType.GetElementType();
         undefined = TypeToCustomAttributeEncoding(parameterType);
     }
     if ((encodedType == CustomAttributeEncoding.Enum) || (undefined == CustomAttributeEncoding.Enum))
     {
         encodedEnumType = TypeToCustomAttributeEncoding((RuntimeType) Enum.GetUnderlyingType(parameterType));
         enumName = parameterType.AssemblyQualifiedName;
     }
     return new CustomAttributeType(encodedType, undefined, encodedEnumType, enumName);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:CustomAttributeData.cs

示例4: GetCustomAttributes

        [System.Security.SecurityCritical]  // auto-generated
        internal static Attribute[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool includeSecCa, out int count)
        {
            Contract.Requires(type != null);
            Contract.Requires(caType != null);

            count = 0;

            bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
            if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
                return new Attribute[0];

            List<Attribute> pcas = new List<Attribute>();
            Attribute pca = null;

#if FEATURE_SERIALIZATION
            if (all || caType == (RuntimeType)typeof(SerializableAttribute))
            {
                pca = SerializableAttribute.GetCustomAttribute(type);
                if (pca != null) pcas.Add(pca);
            }
#endif 
            if (all || caType == (RuntimeType)typeof(ComImportAttribute))
            {
                pca = ComImportAttribute.GetCustomAttribute(type);
                if (pca != null) pcas.Add(pca);
            }
            if (includeSecCa && (all || IsSecurityAttribute(caType)))
            {
                if (!type.IsGenericParameter && type.GetElementType() == null)
                {
                    if (type.IsGenericType)
                        type = (RuntimeType)type.GetGenericTypeDefinition();

                    object[] securityAttributes;
                    GetSecurityAttributes(type.Module.ModuleHandle.GetRuntimeModule(), type.MetadataToken, false, out securityAttributes);
                    if (securityAttributes != null)
                        foreach (object a in securityAttributes)
                            if (caType == a.GetType() || a.GetType().IsSubclassOf(caType))
                                pcas.Add((Attribute)a);
                }
            }

            count = pcas.Count;
            return pcas.ToArray();
        }
开发者ID:enavro,项目名称:coreclr,代码行数:46,代码来源:CustomAttribute.cs

示例5: 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

示例6: IsDefined

 internal static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
 {
     if (type.GetElementType() == null)
     {
         if (PseudoCustomAttribute.IsDefined(type, caType))
         {
             return true;
         }
         if (IsCustomAttributeDefined(type.Module, type.MetadataToken, caType))
         {
             return true;
         }
         if (!inherit)
         {
             return false;
         }
         type = type.BaseType as RuntimeType;
         while (type != null)
         {
             if (IsCustomAttributeDefined(type.Module, type.MetadataToken, caType, inherit))
             {
                 return true;
             }
             type = type.BaseType as RuntimeType;
         }
     }
     return false;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:28,代码来源:CustomAttribute.cs

示例7: GetCustomAttributes

 internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
 {
     if (type.GetElementType() != null)
     {
         if (!caType.IsValueType)
         {
             return (object[]) Array.CreateInstance(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.Module, type.MetadataToken, count, caType);
         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 != typeof(object)) && (type != null))
     {
         object[] objArray2 = GetCustomAttributes(type.Module, type.MetadataToken, 0, caType, mustBeInheritable, derivedAttributes);
         mustBeInheritable = true;
         for (int i = 0; i < objArray2.Length; i++)
         {
             derivedAttributes.Add(objArray2[i]);
         }
         type = type.BaseType as RuntimeType;
     }
     object[] destinationArray = Array.CreateInstance(elementType, derivedAttributes.Count) as object[];
     Array.Copy(derivedAttributes.ToArray(), 0, destinationArray, 0, derivedAttributes.Count);
     return destinationArray;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:46,代码来源:CustomAttribute.cs

示例8: 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

示例9: GetCustomAttributes

 internal static Attribute[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool includeSecCa, out int count)
 {
     count = 0;
     bool flag = (caType == ((RuntimeType) typeof(object))) || (caType == ((RuntimeType) typeof(Attribute)));
     if ((!flag && (s_pca.GetValueOrDefault(caType) == null)) && !IsSecurityAttribute(caType))
     {
         return new Attribute[0];
     }
     List<Attribute> list = new List<Attribute>();
     Attribute item = null;
     if (flag || (caType == ((RuntimeType) typeof(SerializableAttribute))))
     {
         item = SerializableAttribute.GetCustomAttribute(type);
         if (item != null)
         {
             list.Add(item);
         }
     }
     if (flag || (caType == ((RuntimeType) typeof(ComImportAttribute))))
     {
         item = ComImportAttribute.GetCustomAttribute(type);
         if (item != null)
         {
             list.Add(item);
         }
     }
     if ((includeSecCa && (flag || IsSecurityAttribute(caType))) && (!type.IsGenericParameter && (type.GetElementType() == null)))
     {
         object[] objArray;
         if (type.IsGenericType)
         {
             type = (RuntimeType) type.GetGenericTypeDefinition();
         }
         GetSecurityAttributes(type.Module.ModuleHandle.GetRuntimeModule(), type.MetadataToken, false, out objArray);
         if (objArray != null)
         {
             foreach (object obj2 in objArray)
             {
                 if ((caType == obj2.GetType()) || obj2.GetType().IsSubclassOf(caType))
                 {
                     list.Add((Attribute) obj2);
                 }
             }
         }
     }
     count = list.Count;
     return list.ToArray();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:48,代码来源:PseudoCustomAttribute.cs


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