本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.GetDelegateTypeOfPossibleExpression方法的典型用法代码示例。如果您正苦于以下问题:C# CType.GetDelegateTypeOfPossibleExpression方法的具体用法?C# CType.GetDelegateTypeOfPossibleExpression怎么用?C# CType.GetDelegateTypeOfPossibleExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.CType
的用法示例。
在下文中一共展示了CType.GetDelegateTypeOfPossibleExpression方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoesInputTypeContain
////////////////////////////////////////////////////////////////////////////////
//
// Input types
//
private bool DoesInputTypeContain(EXPR pSource, CType pDest,
TypeParameterType pParam)
{
// SPEC: If E is a method group or an anonymous function and T is a delegate
// SPEC: CType or expression tree CType then all the parameter types of T are
// SPEC: input types of E with CType T.
pDest = pDest.GetDelegateTypeOfPossibleExpression();
if (!pDest.isDelegateType())
{
return false; // No input types.
}
if (!pSource.isUNBOUNDLAMBDA() && !pSource.isMEMGRP())
{
return false; // No input types.
}
TypeArray pDelegateParameters =
pDest.AsAggregateType().GetDelegateParameters(GetSymbolLoader());
if (pDelegateParameters == null)
{
return false;
}
return TypeManager.ParametersContainTyVar(pDelegateParameters, pParam);
}
示例2: DoesOutputTypeContain
////////////////////////////////////////////////////////////////////////////////
//
// Output types
//
private bool DoesOutputTypeContain(EXPR pSource, CType pDest,
TypeParameterType pParam)
{
// SPEC: If E is a method group or an anonymous function and T is a delegate
// SPEC: CType or expression tree CType then the return CType of T is an output CType
// SPEC: of E with CType T.
pDest = pDest.GetDelegateTypeOfPossibleExpression();
if (!pDest.isDelegateType())
{
return false;
}
if (!pSource.isUNBOUNDLAMBDA() && !pSource.isMEMGRP())
{
return false;
}
CType pDelegateReturn = pDest.AsAggregateType().GetDelegateReturnType(GetSymbolLoader());
if (pDelegateReturn == null)
{
return false;
}
return TypeManager.TypeContainsType(pDelegateReturn, pParam);
}
示例3: MethodGroupReturnTypeInference
////////////////////////////////////////////////////////////////////////////////
private bool MethodGroupReturnTypeInference(EXPR pSource, CType pType)
{
// SPEC: Otherwise, if E is a method group and T is a delegate CType or
// SPEC: expression tree CType with parameter types T1...Tk and return
// SPEC: CType Tb and overload resolution of E with the types T1...Tk
// SPEC: yields a single method with return CType U then a lower-bound
// SPEC: inference is made from U to Tb.
if (!pSource.isMEMGRP())
{
return false;
}
pType = pType.GetDelegateTypeOfPossibleExpression();
if (!pType.isDelegateType())
{
return false;
}
AggregateType pDelegateType = pType.AsAggregateType();
CType pDelegateReturnType = pDelegateType.GetDelegateReturnType(GetSymbolLoader());
if (pDelegateReturnType == null)
{
return false;
}
if (pDelegateReturnType.IsVoidType())
{
return false;
}
// At this point we are in the second phase; we know that all the input types are fixed.
TypeArray pDelegateParameters = GetFixedDelegateParameters(pDelegateType);
if (pDelegateParameters == null)
{
return false;
}
ArgInfos argInfo = new ArgInfos() { carg = pDelegateParameters.size, types = pDelegateParameters, fHasExprs = false, prgexpr = null };
var argsBinder = new ExpressionBinder.GroupToArgsBinder(_binder, 0/* flags */, pSource.asMEMGRP(), argInfo, null, false, pDelegateType);
bool success = argsBinder.Bind(false);
if (!success)
{
return false;
}
MethPropWithInst mwi = argsBinder.GetResultsOfBind().GetBestResult();
CType pMethodReturnType = GetTypeManager().SubstType(mwi.Meth().RetType,
mwi.GetType(), mwi.TypeArgs);
if (pMethodReturnType.IsVoidType())
{
return false;
}
LowerBoundInference(pMethodReturnType, pDelegateReturnType);
return true;
}