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


C# IType.GetInterfaces方法代码示例

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


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

示例1: WriteRttiClassInfoDefinition

        /// <summary>
        /// </summary>
        /// <param name="type">
        /// </param>
        /// <param name="llvmWriter">
        /// </param>
        public static void WriteRttiClassInfoDefinition(IType type, LlvmWriter llvmWriter)
        {
            var writer = llvmWriter.Output;

            var @interfaces = type.GetInterfaces();

            writer.WriteLine("{");
            writer.Indent++;
            writer.WriteLine(
                "i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i32 2) to i8*),");
            writer.WriteLine(
                "i8* getelementptr inbounds ([{1} x i8]* @\"{0}\", i32 0, i32 0),",
                type.GetRttiStringName(),
                type.StringLength());
            writer.WriteLine("i32 0,");
            writer.WriteLine("i32 {0}", @interfaces.Count() + (type.BaseType != null ? 1 : 0));

            var nextFlag = 2;

            if (type.BaseType != null)
            {
                writer.Write(",i8* bitcast (");
                type.BaseType.WriteRttiClassInfoDeclaration(writer);
                writer.WriteLine("* @\"{0}\" to i8*),", type.BaseType.GetRttiInfoName());

                // if class does not have any virtual method then next value should be 0, else 2 (and next class should be +1024)
                writer.WriteLine("i32 {0}", nextFlag);

                // apply fields shift + base item
                // nextFlag += 1024 * (type.BaseType.GetFieldsShift() + 1);
                nextFlag += 1024 * (type.BaseType.GetTypeSize(llvmWriter) / LlvmWriter.PointerSize);
            }

            foreach (var @interface in type.GetInterfaces())
            {
                writer.Write(",i8* bitcast (");
                @interface.WriteRttiClassInfoDeclaration(writer);
                writer.WriteLine("* @\"{0}\" to i8*),", @interface.GetRttiInfoName());
                writer.WriteLine("i32 {0}", nextFlag);
                nextFlag += 1024;
            }

            writer.Indent--;
            writer.WriteLine("}");
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:51,代码来源:RttiClassWithBaseAndInterfaces.cs

示例2: SynthesizedGetTypeMethod

 /// <summary>
 /// </summary>
 /// <param name="type">
 /// </param>
 /// <param name="typeResolver">
 /// </param>
 public SynthesizedGetTypeMethod(IType type, ITypeResolver typeResolver)
     : base(Name, type, typeResolver.System.System_Type)
 {
     if (type.IsObject || (type.IsInterface && !type.GetInterfaces().Any()))
     {
         IsVirtual = true;
     }
     else
     {
         IsOverride = true;
     }
 }
开发者ID:afrog33k,项目名称:csnative,代码行数:18,代码来源:SynthesizedGetTypeMethod.cs

示例3: WriteRttiClassInfoDeclaration

        /// <summary>
        /// </summary>
        /// <param name="type">
        /// </param>
        /// <param name="writer">
        /// </param>
        public static void WriteRttiClassInfoDeclaration(IType type, IndentedTextWriter writer)
        {
            writer.Write("{ i8*, i8*, i32, i32");

            if (type.BaseType != null)
            {
                writer.Write(", i8*, i32");
            }

            foreach (var @interface in type.GetInterfaces())
            {
                writer.Write(", i8*, i32");
            }

            writer.Write(" }");
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:22,代码来源:RttiClassWithBaseAndInterfaces.cs

示例4: WriteRttiClassInfoDefinition

        /// <summary>
        /// </summary>
        /// <param name="type">
        /// </param>
        /// <param name="llvmWriter">
        /// </param>
        public static void WriteRttiClassInfoDefinition(IType type, LlvmWriter llvmWriter)
        {
            var writer = llvmWriter.Output;

            writer.WriteLine("{");
            writer.Indent++;
            writer.WriteLine("i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i32 2) to i8*),");
            writer.WriteLine("i8* getelementptr inbounds ([{1} x i8]* @\"{0}\", i32 0, i32 0),", type.GetRttiStringName(), type.StringLength());
            writer.Write("i8* bitcast (");

            var singleInheritanceType = type.GetInterfaces().First();

            singleInheritanceType.WriteRttiClassInfoDeclaration(writer);
            writer.WriteLine("* @\"{0}\" to i8*)", singleInheritanceType.GetRttiInfoName());
            writer.Indent--;
            writer.WriteLine("}");
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:23,代码来源:RttiClassWithNoBaseAndSingleInterface.cs

示例5: FindConstructedTypes

		/// <summary>
		/// Finds types constructed from the specified definition in the specified type's interfaces and base types.
		/// </summary>
		/// <param name="type">The type in whose hierarchy to search for constructed types.</param>
		/// <param name="definition">The generic type definition whose constructed versions to search for.</param>
		/// <returns>Yields the matching types.</returns>
		public static IEnumerable<IType> FindConstructedTypes(IType type, IType definition)
		{
			while (type != null)
			{
				if (type.ConstructedInfo != null &&
				    type.ConstructedInfo.GenericDefinition == definition)
				{
					yield return type;
				}

				IType[] interfaces = type.GetInterfaces();
				if (interfaces != null)
				{
					foreach (IType interfaceType in interfaces)
					{
						foreach (IType match in FindConstructedTypes(interfaceType, definition))
						{
							yield return match;
						}
					}
				}

				type = type.BaseType;
			}
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:31,代码来源:GenericsServices.cs

示例6: ResolveInterfaceMembers

        void ResolveInterfaceMembers(ClassDefinition node,
			TypeReference baseTypeRef,
			IType baseType)
        {
            foreach (IType entity in baseType.GetInterfaces())
            {
                ResolveInterfaceMembers(node, baseTypeRef, entity);
            }

            foreach (IMember entity in baseType.GetMembers())
            {
                ResolveAbstractMember(node, baseTypeRef, entity);
            }
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:14,代码来源:ProcessInheritedAbstractMembers.cs

示例7: GetDefaultMember

		public IEntity GetDefaultMember(IType type)
		{
			// Search for a default member on this type or any of its non-interface basetypes
			for (IType t = type; t != null; t = t.BaseType)
			{
				IEntity member = t.GetDefaultMember();
				if (member != null) return member;
			}

			// Search for default members on the type's interfaces
			var buffer = new Set<IEntity>();
			foreach (IType interfaceType in type.GetInterfaces())
			{
				IEntity member = GetDefaultMember(interfaceType);
				if (member != null) buffer.Add(member);
			}
			return Entities.EntityFromList(buffer);
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:18,代码来源:TypeSystemServices.cs

示例8: FindConstructedTypes

        /// <summary>
        /// Finds types constructed from the specified definition in the specified type's interfaces and base types.
        /// </summary>
        /// <param name="type">The type in whose hierarchy to search for constructed types.</param>
        /// <param name="definition">The generic type definition whose constructed versions to search for.</param>
        /// <returns>Yields the matching types.</returns>
        public static IEnumerable<IType> FindConstructedTypes(IType type, IType definition)
        {
            while (type != null)
            {
                // Check if type itself is constructed from the definition
                if (type.ConstructedInfo != null &&
                    type.ConstructedInfo.GenericDefinition == definition)
                {
                    yield return type;
                }

                // Look in type's immediate interfaces
                IType[] interfaces = type.GetInterfaces();
                if (interfaces != null)
                {
                    foreach (IType interfaceType in interfaces)
                    {
                        foreach (IType match in FindConstructedTypes(interfaceType, definition))
                        {
                            yield return match;
                        }
                    }
                }

                // Move on to the type's base type
                type = type.BaseType;
            }
        }
开发者ID:boo,项目名称:boo-lang,代码行数:34,代码来源:GenericsServices.cs

示例9: AddMethodsToVirtualInterfaceTableLayout

        /// <summary>
        /// </summary>
        /// <param name="virtualTable">
        /// </param>
        /// <param name="interface">
        /// </param>
        private static void AddMethodsToVirtualInterfaceTableLayout(this List<IMethod> virtualTable, IType @interface)
        {
            var allInterfaces = @interface.GetInterfaces();
            var firstChildInterface = allInterfaces != null ? allInterfaces.FirstOrDefault() : null;
            if (firstChildInterface != null)
            {
                // get all virtual methods in current type and replace or append
                virtualTable.AddMethodsToVirtualInterfaceTableLayout(firstChildInterface);
            }

            // get all virtual methods in current type and replace or append
            virtualTable.AddRange(IlReader.Methods(@interface));
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:19,代码来源:VirtualTableGen.cs

示例10: AddMethodsToVirtualInterfaceTable

        /// <summary>
        /// </summary>
        /// <param name="virtualTable">
        /// </param>
        /// <param name="interface">
        /// </param>
        /// <param name="allPublic">
        /// </param>
        private static void AddMethodsToVirtualInterfaceTable(
            this List<LlvmWriter.Pair<IMethod, IMethod>> virtualTable, IType @interface, IEnumerable<IMethod> allPublic)
        {
            var allInterfaces = @interface.GetInterfaces();
            var firstChildInterface = allInterfaces != null ? allInterfaces.FirstOrDefault() : null;
            if (firstChildInterface != null)
            {
                // get all virtual methods in current type and replace or append
                virtualTable.AddMethodsToVirtualInterfaceTable(firstChildInterface, allPublic);
            }

            // get all virtual methods in current type and replace or append
            var list = IlReader.Methods(@interface)
                        .Select(interfaceMember => allPublic.Where(interfaceMember.IsMatchingInterfaceOverride).OrderByDescending(x => x.IsExplicitInterfaceImplementation).FirstOrDefault())
                        .Select(foundMethod => new LlvmWriter.Pair<IMethod, IMethod> { Key = foundMethod, Value = foundMethod }).ToList();

#if !FOR_MSCORLIBTEST
            Debug.Assert(list.All(i => i.Value != null), "Not all method could be resolved");
#endif

            virtualTable.AddRange(list);
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:30,代码来源:VirtualTableGen.cs

示例11: IterateAllRequiredTypes

        private static IEnumerable<IType> IterateAllRequiredTypes(IType type, ReadingTypesContext readingTypesContext)
        {
            Debug.Assert(type != null, "Type is null");

            if (type.BaseType != null)
            {
                DicoverGenericSpecializedTypesAndAdditionalTypes(type.BaseType, readingTypesContext);
                yield return type.BaseType;
            }

            if (type.HasElementType)
            {
                DicoverGenericSpecializedTypesAndAdditionalTypes(type.GetElementType(), readingTypesContext);
                yield return type.GetElementType();
            }

            var interfaces = type.GetInterfaces();
            if (interfaces != null)
            {
                foreach (var @interface in interfaces)
                {
                    DicoverGenericSpecializedTypesAndAdditionalTypes(@interface, readingTypesContext);
                    yield return @interface;
                }
            }

            if (!type.IsInterface)
            {
                var fields = IlReader.Fields(
                    type, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, _codeWriter);
                foreach (var field in fields)
                {
                    ////#if DEBUG
                    ////    Debug.WriteLine("Processing field: {0}, Type: {1}", field.FullName, field.FieldType);
                    ////#endif

                    DicoverGenericSpecializedTypesAndAdditionalTypes(field.FieldType, readingTypesContext);
                    if (field.FieldType.IsStructureType() && !field.FieldType.IsPointer)
                    {
                        yield return field.FieldType;
                    }
                }

                var ctors = IlReader.Constructors(
                    type, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, _codeWriter);
                foreach (var requiredType in ctors.SelectMany(ctor => GetAllRequiredTypesForMethod(ctor, readingTypesContext)))
                {
                    yield return requiredType;
                }
            }

            var methods = IlReader.Methods(
                type, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, _codeWriter);
            foreach (var requiredType in methods.SelectMany(method => GetAllRequiredTypesForMethod(method, readingTypesContext)))
            {
                yield return requiredType;
            }
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:58,代码来源:Il2Converter.cs


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