本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.GetNakedType方法的典型用法代码示例。如果您正苦于以下问题:C# CType.GetNakedType方法的具体用法?C# CType.GetNakedType怎么用?C# CType.GetNakedType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.CType
的用法示例。
在下文中一共展示了CType.GetNakedType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckTypeAccess
public virtual bool CheckTypeAccess(CType type, Symbol symWhere)
{
Debug.Assert(type != null);
// Array, Ptr, Nub, etc don't matter.
type = type.GetNakedType(true);
if (!type.IsAggregateType())
{
Debug.Assert(type.IsVoidType() || type.IsErrorType() || type.IsTypeParameterType());
return true;
}
for (AggregateType ats = type.AsAggregateType(); ats != null; ats = ats.outerType)
{
if (ACCESSERROR.ACCESSERROR_NOERROR != CheckAccessCore(ats.GetOwningAggregate(), ats.outerType, symWhere, null))
{
return false;
}
}
TypeArray typeArgs = type.AsAggregateType().GetTypeArgsAll();
for (int i = 0; i < typeArgs.size; i++)
{
if (!CheckTypeAccess(typeArgs.Item(i), symWhere))
return false;
}
return true;
}
示例2: CheckConstraints
// Check the constraints of any type arguments in the given Type.
public static bool CheckConstraints(CSemanticChecker checker, ErrorHandling errHandling, CType type, CheckConstraintsFlags flags)
{
type = type.GetNakedType(false);
if (type.IsNullableType())
{
CType typeT = type.AsNullableType().GetAts(checker.GetErrorContext());
if (typeT != null)
type = typeT;
else
type = type.GetNakedType(true);
}
if (!type.IsAggregateType())
return true;
AggregateType ats = type.AsAggregateType();
if (ats.GetTypeArgsAll().size == 0)
{
// Common case: there are no type vars, so there are no constraints.
ats.fConstraintsChecked = true;
ats.fConstraintError = false;
return true;
}
if (ats.fConstraintsChecked)
{
// Already checked.
if (!ats.fConstraintError || (flags & CheckConstraintsFlags.NoDupErrors) != 0)
{
// No errors or no need to report errors again.
return !ats.fConstraintError;
}
}
TypeArray typeVars = ats.getAggregate().GetTypeVars();
TypeArray typeArgsThis = ats.GetTypeArgsThis();
TypeArray typeArgsAll = ats.GetTypeArgsAll();
Debug.Assert(typeVars.size == typeArgsThis.size);
if (!ats.fConstraintsChecked)
{
ats.fConstraintsChecked = true;
ats.fConstraintError = false;
}
// Check the outer type first. If CheckConstraintsFlags.Outer is not specified and the
// outer type has already been checked then don't bother checking it.
if (ats.outerType != null && ((flags & CheckConstraintsFlags.Outer) != 0 || !ats.outerType.fConstraintsChecked))
{
CheckConstraints(checker, errHandling, ats.outerType, flags);
ats.fConstraintError |= ats.outerType.fConstraintError;
}
if (typeVars.size > 0)
ats.fConstraintError |= !CheckConstraintsCore(checker, errHandling, ats.getAggregate(), typeVars, typeArgsThis, typeArgsAll, null, (flags & CheckConstraintsFlags.NoErrors));
// Now check type args themselves.
for (int i = 0; i < typeArgsThis.size; i++)
{
CType arg = typeArgsThis.Item(i).GetNakedType(true);
if (arg.IsAggregateType() && !arg.AsAggregateType().fConstraintsChecked)
{
CheckConstraints(checker, errHandling, arg.AsAggregateType(), flags | CheckConstraintsFlags.Outer);
if (arg.AsAggregateType().fConstraintError)
ats.fConstraintError = true;
}
}
return !ats.fConstraintError;
}