private static bool CanAssignToConcreteType(ClrType assignee, StructuredType targetType) { while (assignee != null) { var assigneeType = structuredTypeFactory.CreateFromClrType(assignee); if (targetType.Equals(assigneeType)) { return(true); } assignee = assignee.BaseType; } return(false); }
private static bool CanAssignToInterfaceType(ClrType assignee, StructuredType targetType) { return(EnumerateInterfaces(assignee).Contains(targetType)); }
public static bool CanBeAssignedTo(this ClrType assignee, StructuredType targetType, bool targetIsInterface) { return(targetIsInterface ? CanAssignToInterfaceType(assignee, targetType) : CanAssignToConcreteType(assignee, targetType)); }