本文整理汇总了C#中Mono.Cecil.TypeReference.GetFriendlyFullName方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.GetFriendlyFullName方法的具体用法?C# TypeReference.GetFriendlyFullName怎么用?C# TypeReference.GetFriendlyFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeReference
的用法示例。
在下文中一共展示了TypeReference.GetFriendlyFullName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreEqual
public static bool AreEqual(TypeReference firstType, TypeReference secondType)
{
if (firstType.GetFriendlyFullName(null) == secondType.GetFriendlyFullName(null))
{
return true;
}
TypeReference firstTypeRef = firstType.GetElementType();
TypeReference secondTypeRef = secondType.GetElementType();
if (firstTypeRef.HasGenericParameters && secondTypeRef.HasGenericParameters)
{
if (firstTypeRef.FullName == secondTypeRef.FullName &&
firstTypeRef.GenericParameters.Count == secondTypeRef.GenericParameters.Count)
{
return true;
}
}
return false;
}
示例2: IsSubtype
/// <summary>
/// Checks if <paramref name="supposedSubType"/> is subtype of <paramref name="type"/>.
/// </summary>
/// <param name="type">The supposed parent type.</param>
/// <param name="supposedSubType">The supposed inheriting type.</param>
/// <returns>Returns True if <paramref name="supposedSubType"/> is subtype of <paramref name="type"/>.</returns>
private bool IsSubtype(TypeReference type, TypeReference supposedSubType)
{
type = RemoveModifiers(type);
supposedSubType = RemoveModifiers(supposedSubType);
if (supposedSubType.GetFriendlyFullName(null) == type.GetFriendlyFullName(null) || type.FullName == "System.Object")
{
///The types are the same, or the check is if a type inherits Object
return true;
}
if (IsArrayAssignable(type, supposedSubType))
{
return true;
}
TypeDefinition supposedSubTypeDef = supposedSubType.Resolve();
if (supposedSubTypeDef == null)
{
//happens with generics only;
return true;
}
if (type is GenericInstanceType)
{
type = type.GetElementType();
}
while (supposedSubTypeDef != null)
{
if (type.GetFriendlyFullName(null) == supposedSubTypeDef.GetFriendlyFullName(null))
{
///Must be here, since mono fails on resolving types sometimes.
return true;
}
foreach (TypeReference @interface in supposedSubTypeDef.Interfaces)
{
if (@interface.Name == type.Name)
{
return true;
}
}
if (supposedSubTypeDef.BaseType == null)
{
///We are at the root of the class hierarcy, and no match was made.
return false;
}
supposedSubTypeDef = supposedSubTypeDef.BaseType.Resolve();
}
return false;
}
示例3: WriteType
protected void WriteType(TypeReference type, ILNameSyntax syntax)
{
if (type is ArrayType)
{
WriteArrayType(type, syntax);
return;
}
string name = ILHelpers.PrimitiveTypeName(type.GetFriendlyFullName(Language));
if (syntax == ILNameSyntax.ShortTypeName)
{
if (name != null)
WriteReference(name, type);
else
WriteReference(ILHelpers.Escape(type.Name), type);
}
else if ((syntax == ILNameSyntax.Signature || syntax == ILNameSyntax.SignatureNoNamedTypeParameters) && name != null)
{
WriteReference(name, type);
}
else
{
if (syntax == ILNameSyntax.Signature || syntax == ILNameSyntax.SignatureNoNamedTypeParameters)
WriteKeyWordPostSpace(type.IsValueType ? "valuetype" : "class");
if (type.DeclaringType != null)
{
WriteTypeReference(type.DeclaringType, ILNameSyntax.TypeName);
WriteKeyword("/");
WriteReference(ILHelpers.Escape(type.Name), type);
}
else
{
if (!type.IsDefinition && type.Scope != null && !(type is TypeSpecification))
{
WriteToken("[");
WriteEscaped(type.Scope.Name);
WriteToken("]");
}
WriteReference(ILHelpers.Escape(type.FullName), type);
}
}
}