本文整理汇总了C#中IType.IsSubtypeOf方法的典型用法代码示例。如果您正苦于以下问题:C# IType.IsSubtypeOf方法的具体用法?C# IType.IsSubtypeOf怎么用?C# IType.IsSubtypeOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.IsSubtypeOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasCorrectType
private bool HasCorrectType(PredefinedType predefinedType, IType type)
{
var typeConversionRule = myOwnerDeclaration.GetTypeConversionRule();
if (type.IsString() || !type.IsSubtypeOf(predefinedType.IEnumerable))
return false;
var parameterDeclaration = myOwnerDeclaration as IRegularParameterDeclaration;
if (parameterDeclaration != null)
return CheckSingleType(predefinedType, myOwnerDeclaration.GetPsiModule(), type, typeConversionRule, parameterDeclaration.Type);
var methodDeclaration = myOwnerDeclaration as IMethodDeclaration;
if (methodDeclaration != null && methodDeclaration.ParameterDeclarations.Count == 1)
return CheckSingleType(predefinedType, myOwnerDeclaration.GetPsiModule(), type, typeConversionRule, methodDeclaration.ParameterDeclarations[0].Type);
return true;
}
示例2: IsEnumerable
/// <summary>Gets a value indicating whether this instance is enumerable.</summary>
/// <param name="type">The type.</param>
/// <returns><c>true</c> if the specified type is enumerable; otherwise, <c>false</c>.</returns>
private bool IsEnumerable(IType type)
{
var enumerable = TypeFactory.CreateTypeByCLRName("System.Collections.IEnumerable", type.Module, type.GetResolveContext());
return type.IsSubtypeOf(enumerable);
}
示例3: CheckSingleType
private static bool CheckSingleType(PredefinedType predefinedType, IPsiModule psiModule, IType type, ITypeConversionRule conversionRule, IType typeInDeclaration)
{
if (!type.IsGenericOrNonIEnumerable())
{
if (!type.IsSubtypeOf(predefinedType.Array))
return true;
IDeclaredType scalarType = type.GetScalarType();
return scalarType != null && scalarType.IsImplicitlyConvertibleTo(typeInDeclaration, conversionRule);
}
IDeclaredType ienumerableOf = CollectionTypeUtil.CreateIEnumerableOf(psiModule, typeInDeclaration);
return ienumerableOf == null || type.IsImplicitlyConvertibleTo(ienumerableOf, conversionRule);
}
示例4: CanAssignTo
public static bool CanAssignTo(IType toType, IType fromType, IType promotedType)
{
return fromType.IsSubtypeOf(toType) || (promotedType != null && promotedType.IsSubtypeOf(toType));
}