本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType.isInterfaceType方法的典型用法代码示例。如果您正苦于以下问题:C# AggregateType.isInterfaceType方法的具体用法?C# AggregateType.isInterfaceType怎么用?C# AggregateType.isInterfaceType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType
的用法示例。
在下文中一共展示了AggregateType.isInterfaceType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: TryVarianceAdjustmentToGetAccessibleType
private bool TryVarianceAdjustmentToGetAccessibleType(CSemanticChecker semanticChecker, BindingContext bindingContext, AggregateType typeSrc, out CType typeDst)
{
Debug.Assert(typeSrc != null);
Debug.Assert(typeSrc.isInterfaceType() || typeSrc.isDelegateType());
typeDst = null;
AggregateSymbol aggSym = typeSrc.GetOwningAggregate();
AggregateType aggOpenType = aggSym.getThisType();
if (!semanticChecker.CheckTypeAccess(aggOpenType, bindingContext.ContextForMemberLookup()))
{
// if the aggregate symbol itself is not accessible, then forget it, there is no
// variance that will help us arrive at an accessible type.
return false;
}
TypeArray typeArgs = typeSrc.GetTypeArgsThis();
TypeArray typeParams = aggOpenType.GetTypeArgsThis();
CType[] newTypeArgsTemp = new CType[typeArgs.size];
for (int i = 0; i < typeArgs.size; i++)
{
if (semanticChecker.CheckTypeAccess(typeArgs.Item(i), bindingContext.ContextForMemberLookup()))
{
// we have an accessible argument, this position is not a problem.
newTypeArgsTemp[i] = typeArgs.Item(i);
continue;
}
if (!typeArgs.Item(i).IsRefType() || !typeParams.Item(i).AsTypeParameterType().Covariant)
{
// This guy is inaccessible, and we are not going to be able to vary him, so we need to fail.
return false;
}
CType intermediateTypeArg;
if (GetBestAccessibleType(semanticChecker, bindingContext, typeArgs.Item(i), out intermediateTypeArg))
{
// now we either have a value type (which must be accessible due to the above
// check, OR we have an inaccessible type (which must be a ref type). In either
// case, the recursion worked out and we are OK to vary this argument.
newTypeArgsTemp[i] = intermediateTypeArg;
continue;
}
else
{
Debug.Assert(false, "GetBestAccessibleType unexpectedly failed on a type that was used as a type parameter");
return false;
}
}
TypeArray newTypeArgs = semanticChecker.getBSymmgr().AllocParams(typeArgs.size, newTypeArgsTemp);
CType intermediateType = this.GetAggregate(aggSym, typeSrc.outerType, newTypeArgs);
// All type arguments were varied successfully, which means now we must be accessible. But we could
// have violated constraints. Let's check that out.
if (!TypeBind.CheckConstraints(semanticChecker, null/*ErrorHandling*/, intermediateType, CheckConstraintsFlags.NoErrors))
{
return false;
}
typeDst = intermediateType;
Debug.Assert(semanticChecker.CheckTypeAccess(typeDst, bindingContext.ContextForMemberLookup()));
return true;
}
示例4: HasInterfaceConversion
////////////////////////////////////////////////////////////////////////////////
// The rules for variant interface and delegate conversions are the same:
//
// An interface/delegate type S is convertible to an interface/delegate type T
// if and only if T is U<S1, ... Sn> and T is U<T1, ... Tn> such that for all
// parameters of U:
//
// * if the ith parameter of U is invariant then Si is exactly equal to Ti.
// * if the ith parameter of U is covariant then either Si is exactly equal
// to Ti, or there is an implicit reference conversion from Si to Ti.
// * if the ith parameter of U is contravariant then either Si is exactly
// equal to Ti, or there is an implicit reference conversion from Ti to Si.
private bool HasInterfaceConversion(AggregateType pSource, AggregateType pDest)
{
Debug.Assert(pSource != null && pSource.isInterfaceType());
Debug.Assert(pDest != null && pDest.isInterfaceType());
return HasVariantConversion(pSource, pDest);
}
示例5: LookupInInterfaces
/******************************************************************************
Returns true if searching should continue to object.
******************************************************************************/
private bool LookupInInterfaces(AggregateType typeStart, TypeArray types)
{
Debug.Assert(!_swtFirst || _fMulti);
Debug.Assert(typeStart == null || typeStart.isInterfaceType());
Debug.Assert(typeStart != null || types.size != 0);
// Clear all the hidden flags. Anything found in a class hides any other
// kind of member in all the interfaces.
if (typeStart != null)
{
typeStart.fAllHidden = false;
typeStart.fDiffHidden = (_swtFirst != null);
}
for (int i = 0; i < types.size; i++)
{
AggregateType type = types.Item(i).AsAggregateType();
Debug.Assert(type.isInterfaceType());
type.fAllHidden = false;
type.fDiffHidden = !!_swtFirst;
}
bool fHideObject = false;
AggregateType typeCur = typeStart;
int itypeNext = 0;
if (typeCur == null)
{
typeCur = types.Item(itypeNext++).AsAggregateType();
}
Debug.Assert(typeCur != null);
// Loop through the interfaces.
for (; ;)
{
Debug.Assert(typeCur != null && typeCur.isInterfaceType());
bool fHideByName = false;
if (!typeCur.fAllHidden && SearchSingleType(typeCur, out fHideByName))
{
fHideByName |= !_fMulti;
// Mark base interfaces appropriately.
TypeArray ifaces = typeCur.GetIfacesAll();
for (int i = 0; i < ifaces.size; i++)
{
AggregateType type = ifaces.Item(i).AsAggregateType();
Debug.Assert(type.isInterfaceType());
if (fHideByName)
type.fAllHidden = true;
type.fDiffHidden = true;
}
// If we hide all base types, that includes object!
if (fHideByName)
fHideObject = true;
}
_flags &= ~MemLookFlags.TypeVarsAllowed;
if (itypeNext >= types.size)
return !fHideObject;
// Substitution has already been done.
typeCur = types.Item(itypeNext++).AsAggregateType();
}
}
示例6: bases
/******************************************************************************
Lookup in a class and its bases (until *ptypeEnd is hit).
ptypeEnd [in/out] - *ptypeEnd should be either null or object. If we find
something here that would hide members of object, this sets *ptypeEnd
to null.
Returns true when searching should continue to the interfaces.
******************************************************************************/
private bool LookupInClass(AggregateType typeStart, ref AggregateType ptypeEnd)
{
Debug.Assert(!_swtFirst || _fMulti);
Debug.Assert(typeStart != null && !typeStart.isInterfaceType() && (ptypeEnd == null || typeStart != ptypeEnd));
AggregateType typeEnd = ptypeEnd;
AggregateType typeCur;
// Loop through types. Loop until we hit typeEnd (object or null).
for (typeCur = typeStart; typeCur != typeEnd && typeCur != null; typeCur = typeCur.GetBaseClass())
{
Debug.Assert(!typeCur.isInterfaceType());
bool fHideByName = false;
SearchSingleType(typeCur, out fHideByName);
_flags &= ~MemLookFlags.TypeVarsAllowed;
if (_swtFirst && !_fMulti)
{
// Everything below this type and in interfaces is hidden.
return false;
}
if (fHideByName)
{
// This hides everything below it and in object, but not in the interfaces!
ptypeEnd = null;
// Return true to indicate that it's ok to search additional types.
return true;
}
if ((_flags & MemLookFlags.Ctor) != 0)
{
// If we're looking for a constructor, don't check base classes or interfaces.
return false;
}
}
Debug.Assert(typeCur == typeEnd);
return true;
}
示例7: type
//.........这里部分代码省略.........
// A bogus member - we can't use these, so only record them for error reporting.
if (!_swtBogus)
{
_swtBogus.Set(symCur, typeCur);
}
continue;
}
// if we are in a calling context then we should only find a property if it is delegate valued
if ((_flags & MemLookFlags.MustBeInvocable) != 0)
{
if ((symCur.IsFieldSymbol() && !IsDelegateType(symCur.AsFieldSymbol().GetType(), typeCur) && !IsDynamicMember(symCur)) ||
(symCur.IsPropertySymbol() && !IsDelegateType(symCur.AsPropertySymbol().RetType, typeCur) && !IsDynamicMember(symCur)))
{
if (!_swtBad)
{
_swtBad.Set(symCur, typeCur);
}
continue;
}
}
if (symCur.IsMethodOrPropertySymbol())
{
MethPropWithType mwpInsert = new MethPropWithType(symCur.AsMethodOrPropertySymbol(), typeCur);
_methPropWithTypeList.Add(mwpInsert);
}
// We have a visible symbol.
fFoundSome = true;
if (_swtFirst)
{
if (!typeCur.isInterfaceType())
{
// Non-interface case.
Debug.Assert(_fMulti || typeCur == _prgtype[0]);
if (!_fMulti)
{
if (_swtFirst.Sym.IsFieldSymbol() && symCur.IsEventSymbol()
#if !CSEE // The isEvent bit is only set on symbols which come from source...
// This is not a problem for the compiler because the field is only
// accessible in the scope in which it is declared,
// but in the EE we ignore accessibility...
&& _swtFirst.Field().isEvent
#endif
)
{
// m_swtFirst is just the field behind the event symCur so ignore symCur.
continue;
}
else if (_swtFirst.Sym.IsFieldSymbol() && symCur.IsEventSymbol())
{
// symCur is the matching event.
continue;
}
goto LAmbig;
}
if (_swtFirst.Sym.getKind() != symCur.getKind())
{
if (typeCur == _prgtype[0])
goto LAmbig;
// This one is hidden by the first one. This one also hides any more in base types.
pfHideByName = true;
continue;
}