本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.AllPossibleInterfaces方法的典型用法代码示例。如果您正苦于以下问题:C# CType.AllPossibleInterfaces方法的具体用法?C# CType.AllPossibleInterfaces怎么用?C# CType.AllPossibleInterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.CType
的用法示例。
在下文中一共展示了CType.AllPossibleInterfaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpperBoundInterfaceInference
////////////////////////////////////////////////////////////////////////////////
private bool UpperBoundInterfaceInference(AggregateType pSource, CType pDest)
{
if (!pSource.isInterfaceType())
{
return false;
}
// SPEC: Otherwise, if U is an interface CType C<U1...Uk> and V is a class CType
// SPEC: or struct CType and there is a unique set V1...Vk such that V directly
// SPEC: or indirectly implements C<V1...Vk> then an exact ...
// SPEC: ... and U is an interface CType ...
if (!pDest.isStructType() && !pDest.isClassType() &&
!pDest.isInterfaceType())
{
return false;
}
var interfaces = pDest.AllPossibleInterfaces();
AggregateType pInterface = null;
foreach (AggregateType pCurrent in interfaces)
{
if (pCurrent.GetOwningAggregate() == pSource.GetOwningAggregate())
{
if (pInterface == null)
{
pInterface = pCurrent;
}
else if (pInterface != pCurrent)
{
// Not unique. Bail out.
return false;
}
}
}
if (pInterface == null)
{
return false;
}
UpperBoundTypeArgumentInference(pInterface, pDest.AsAggregateType());
return true;
}
示例2: LowerBoundInterfaceInference
////////////////////////////////////////////////////////////////////////////////
private bool LowerBoundInterfaceInference(CType pSource, AggregateType pDest)
{
if (!pDest.isInterfaceType())
{
return false;
}
// SPEC: Otherwise, if V is an interface CType C<V1...Vk> and U is a class CType
// SPEC: or struct CType and there is a unique set U1...Uk such that U directly
// SPEC: or indirectly implements C<U1...Uk> then an
// SPEC: exact, upper-bound, or lower-bound inference ...
// SPEC: ... and U is an interface CType ...
// SPEC: ... and U is a CType parameter ...
//TypeArray pInterfaces = null;
if (!pSource.isStructType() && !pSource.isClassType() &&
!pSource.isInterfaceType() && !pSource.IsTypeParameterType())
{
return false;
}
var interfaces = pSource.AllPossibleInterfaces();
AggregateType pInterface = null;
foreach (AggregateType pCurrent in interfaces)
{
if (pCurrent.GetOwningAggregate() == pDest.GetOwningAggregate())
{
if (pInterface == null)
{
pInterface = pCurrent;
}
else if (pInterface != pCurrent)
{
// Not unique. Bail out.
return false;
}
}
}
if (pInterface == null)
{
return false;
}
LowerBoundTypeArgumentInference(pInterface, pDest);
return true;
}