本文整理汇总了C#中Type.IsEquivalentTo方法的典型用法代码示例。如果您正苦于以下问题:C# Type.IsEquivalentTo方法的具体用法?C# Type.IsEquivalentTo怎么用?C# Type.IsEquivalentTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.IsEquivalentTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreEquivalent
internal static bool AreEquivalent(Type t1, Type t2)
{
#if CLR2 || SILVERLIGHT
return t1 == t2;
#else
return t1 == t2 || t1.IsEquivalentTo(t2);
#endif
}
示例2: AreTypesEquivalent
/// <summary>
/// Determines if two CLR types are equivalent.
/// </summary>
/// <param name="typeA">First type to compare.</param>
/// <param name="typeB">Second type to compare.</param>
/// <returns>true if the types are equivalent (they both represent the same type), or false otherwise.</returns>
/// <remarks>This method abstracts away the necessity to call Type.IsEquivalentTo method in .NET 4 and higher but
/// use simple reference equality on platforms which don't have that method (like Silverlight).</remarks>
internal static bool AreTypesEquivalent(Type typeA, Type typeB)
{
DebugUtils.CheckNoExternalCallers();
if (typeA == null || typeB == null)
{
return false;
}
else
{
#if SILVERLIGHT || WINDOWS_PHONE || ORCAS
return typeA == typeB;
#else
return typeA.IsEquivalentTo(typeB);
#endif
}
}
示例3: AreEquivalent
public static bool AreEquivalent(Type t1, Type t2)
{
return t1.IsEquivalentTo(t2);
}
示例4: GetMethod
/// <summary>
/// Find ApplyTo method.
/// </summary>
/// <param name="type"></param>
/// <param name="exact"></param>
/// <returns></returns>
internal static MethodInfo GetMethod(Type type, bool exact)
{
var methods = typeof(Theme).GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
foreach (var method in methods)
{
if (method.Name != "ApplyTo")
continue;
var @params = method.GetParameters();
if (@params.Length == 1 &&
exact ? type.IsEquivalentTo(@params[0].ParameterType)
: type.IsSubclassOf(@params[0].ParameterType))
return method;
}
return null;
}
示例5: AreEquivalent
internal static bool AreEquivalent(Type t1, Type t2)
{
#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
return t1 == t2;
#else
return t1 == t2 || t1.IsEquivalentTo(t2);
#endif
}
示例6: AreEquivalent
internal static bool AreEquivalent(Type t1, Type t2) {
#if FEATURE_TYPE_EQUIVALENCE
return t1 == t2 || t1.IsEquivalentTo(t2);
#else
return t1 == t2;
#endif
}