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


C# RuntimeType.GetInterfaces方法代码示例

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


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

示例1: TypeInfo

 internal TypeInfo(RuntimeType typeOfObj)
 {
     this.ServerType = GetQualifiedTypeName(typeOfObj);
     RuntimeType baseType = (RuntimeType) typeOfObj.BaseType;
     int num = 0;
     while ((baseType != typeof(MarshalByRefObject)) && (baseType != null))
     {
         baseType = (RuntimeType) baseType.BaseType;
         num++;
     }
     string[] strArray = null;
     if (num > 0)
     {
         strArray = new string[num];
         baseType = (RuntimeType) typeOfObj.BaseType;
         for (int i = 0; i < num; i++)
         {
             strArray[i] = GetQualifiedTypeName(baseType);
             baseType = (RuntimeType) baseType.BaseType;
         }
     }
     this.ServerHierarchy = strArray;
     Type[] interfaces = typeOfObj.GetInterfaces();
     string[] strArray2 = null;
     bool isInterface = typeOfObj.IsInterface;
     if ((interfaces.Length > 0) || isInterface)
     {
         strArray2 = new string[interfaces.Length + (isInterface ? 1 : 0)];
         for (int j = 0; j < interfaces.Length; j++)
         {
             strArray2[j] = GetQualifiedTypeName((RuntimeType) interfaces[j]);
         }
         if (isInterface)
         {
             strArray2[strArray2.Length - 1] = GetQualifiedTypeName(typeOfObj);
         }
     }
     this.InterfacesImplemented = strArray2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:TypeInfo.cs

示例2: TypeInfo

        [System.Security.SecurityCritical]  // auto-generated 
        internal TypeInfo(RuntimeType typeOfObj)
        { 
            ServerType = GetQualifiedTypeName(typeOfObj);

            // Compute the length of the server hierarchy
            RuntimeType currType = (RuntimeType)typeOfObj.BaseType; 
            // typeOfObj is the root of all classes, but not included in the hierarachy.
            Message.DebugOut("RemotingServices::TypeInfo: Determining length of server heirarchy\n"); 
            int hierarchyLen = 0; 
            while ((currType != typeof(MarshalByRefObject)) &&
                   (currType != null)) 
            {
                currType = (RuntimeType)currType.BaseType;
                hierarchyLen++;
            } 

            // Allocate an array big enough to store the hierarchy 
            Message.DebugOut("RemotingServices::TypeInfo: Determined length of server heirarchy\n"); 
            String[] serverHierarchy = null;
            if (hierarchyLen > 0) 
            {
                serverHierarchy = new String[hierarchyLen];

                currType = (RuntimeType)typeOfObj.BaseType; 
                for (int i = 0; i < hierarchyLen; i++)
                { 
                    serverHierarchy[i] = GetQualifiedTypeName(currType); 
                    currType = (RuntimeType)currType.BaseType;
                } 
            }

            this.ServerHierarchy = serverHierarchy;
 
            Message.DebugOut("RemotingServices::TypeInfo: Getting implemented interfaces\n");
            // Set the interfaces implemented 
            Type[] interfaces = typeOfObj.GetInterfaces(); 
            String[] interfaceNames = null;
            // If the requested type itself is an interface we should add that to the 
            // interfaces list as well
            bool isInterface = typeOfObj.IsInterface;
            if (interfaces.Length > 0 || isInterface)
            { 
                interfaceNames = new String[interfaces.Length + (isInterface ? 1 : 0)];
                for (int i = 0; i < interfaces.Length; i++) 
                { 
                    interfaceNames[i] = GetQualifiedTypeName((RuntimeType)interfaces[i]);
                } 
                if (isInterface)
                    interfaceNames[interfaceNames.Length - 1] = GetQualifiedTypeName(typeOfObj);
            }
 
            this.InterfacesImplemented = interfaceNames;
        } // TypeInfo 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:54,代码来源:ObjRef.cs


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