本文整理汇总了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;
}
示例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