本文整理汇总了C#中IType.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# IType.IsNull方法的具体用法?C# IType.IsNull怎么用?C# IType.IsNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.IsNull方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertTypeCompatibility
public bool AssertTypeCompatibility(Node sourceNode, IType expectedType, IType actualType)
{
if (IsError(expectedType) || IsError(actualType))
return false;
if (expectedType.IsPointer && actualType.IsPointer)
return true; //if both types are unmanaged pointers casting is always possible
if (TypeSystemServices.IsNullable(expectedType) && actualType.IsNull())
return true;
if (!CanBeReachedFrom(sourceNode, expectedType, actualType))
{
_errors.Instance.Add(CompilerErrorFactory.IncompatibleExpressionType(sourceNode, expectedType, actualType));
return false;
}
return true;
}
示例2: MapNullToObject
IType MapNullToObject(IType type)
{
// FIXME: refactor to TypeSystemServices
if (type.IsNull())
return TypeSystemServices.ObjectType;
if (EmptyArrayType.Default == type)
return TypeSystemServices.ObjectArrayType;
return type;
}
示例3: SystemTypeFrom
private Type SystemTypeFrom(IType entity)
{
var external = entity as ExternalType;
if (null != external)
return external.ActualType;
if (entity.IsArray)
{
IArrayType arrayType = (IArrayType)entity;
Type systemType = GetSystemType(arrayType.ElementType);
int rank = arrayType.Rank;
if (rank == 1) return systemType.MakeArrayType();
return systemType.MakeArrayType(rank);
}
if (entity.ConstructedInfo != null)
{
// Type is a constructed generic type - create it using its definition's system type
Type[] arguments = Array.ConvertAll<IType, Type>(entity.ConstructedInfo.GenericArguments, GetSystemType);
return GetSystemType(entity.ConstructedInfo.GenericDefinition).MakeGenericType(arguments);
}
if (entity.IsNull())
return Types.Object;
if (entity is InternalGenericParameter)
return (Type)GetBuilder(((InternalGenericParameter)entity).Node);
if (entity is AbstractInternalType)
{
TypeDefinition typedef = ((AbstractInternalType) entity).TypeDefinition;
var type = (Type)GetBuilder(typedef);
if (null != entity.GenericInfo && !type.IsGenericType) //hu-oh, early-bound
DefineGenericParameters(typedef);
if (entity.IsPointer && null != type)
return type.MakePointerType();
return type;
}
return null;
}
示例4: CanBeReachedByPromotionImpl
private bool CanBeReachedByPromotionImpl(IType expectedType, IType actualType)
{
if (IsNullable(expectedType) && actualType.IsNull())
return true;
if (IsIntegerNumber(actualType) && CanBeExplicitlyCastToPrimitiveNumber(expectedType))
return true;
if (IsIntegerNumber(expectedType) && CanBeExplicitlyCastToPrimitiveNumber(actualType))
return true;
return (expectedType.IsValueType && IsNumber(expectedType) && IsNumber(actualType));
}
示例5: MapWildcardType
public IType MapWildcardType(IType type)
{
if (type.IsNull())
return ObjectType;
if (EmptyArrayType.Default == type)
return ObjectArrayType;
return type;
}
示例6: IsCallableTypeAssignableFrom
public bool IsCallableTypeAssignableFrom(ICallableType lhs, IType rhs)
{
if (lhs == rhs) return true;
if (rhs.IsNull()) return true;
var other = rhs as ICallableType;
if (null == other) return false;
CallableSignature lvalue = lhs.GetSignature();
CallableSignature rvalue = other.GetSignature();
if (lvalue == rvalue) return true;
IParameter[] lparams = lvalue.Parameters;
IParameter[] rparams = rvalue.Parameters;
if (lparams.Length < rparams.Length) return false;
for (int i = 0; i < rparams.Length; ++i)
if (!CanBeReachedFrom(lparams[i].Type, rparams[i].Type))
return false;
return CompatibleReturnTypes(lvalue, rvalue);
}
示例7: IsAssignableFrom
public virtual bool IsAssignableFrom(IType other)
{
if (other == this || other.IsNull())
return true;
if (!other.IsArray)
return false;
var otherArray = (IArrayType)other;
if (otherArray.Rank != _rank)
return false;
if (otherArray == EmptyArrayType.Default)
return true;
IType otherElementType = otherArray.ElementType;
return IsAssignableFrom(_elementType, otherElementType);
}
示例8: IsAssignableFrom
public virtual bool IsAssignableFrom(IType other)
{
if (other == this)
return true;
if (other.IsNull())
return IsClass;
var otherParameter = other as IGenericParameter;
if (otherParameter != null && Array.Exists(otherParameter.GetTypeConstraints(), constraint => TypeCompatibilityRules.IsAssignableFrom(this, constraint)))
return true;
return false;
}
示例9: IsAssignableFrom
public virtual bool IsAssignableFrom(IType other)
{
if (other == null)
return false;
if (other == this || other.IsSubclassOf(this) || (other.IsNull() && !IsValueType))
return true;
return false;
}