本文整理汇总了C#中Mono.CSharp.TypeInferenceContext.InflateGenericArgument方法的典型用法代码示例。如果您正苦于以下问题:C# TypeInferenceContext.InflateGenericArgument方法的具体用法?C# TypeInferenceContext.InflateGenericArgument怎么用?C# TypeInferenceContext.InflateGenericArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.TypeInferenceContext
的用法示例。
在下文中一共展示了TypeInferenceContext.InflateGenericArgument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyParameterCompatibility
protected bool VerifyParameterCompatibility (ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type, AParametersCollection invoke_pd, bool ignore_errors)
{
if (Parameters.Count != invoke_pd.Count) {
if (ignore_errors)
return false;
ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
delegate_type.GetSignatureForError (), Parameters.Count.ToString ());
return false;
}
bool has_implicit_parameters = !HasExplicitParameters;
bool error = false;
for (int i = 0; i < Parameters.Count; ++i) {
Parameter.Modifier p_mod = invoke_pd.FixedParameters [i].ModFlags;
if (Parameters.FixedParameters [i].ModFlags != p_mod && p_mod != Parameter.Modifier.PARAMS) {
if (ignore_errors)
return false;
if (p_mod == Parameter.Modifier.NONE)
ec.Report.Error (1677, Parameters[i].Location, "Parameter `{0}' should not be declared with the `{1}' keyword",
(i + 1).ToString (), Parameter.GetModifierSignature (Parameters [i].ModFlags));
else
ec.Report.Error (1676, Parameters[i].Location, "Parameter `{0}' must be declared with the `{1}' keyword",
(i+1).ToString (), Parameter.GetModifierSignature (p_mod));
error = true;
}
if (has_implicit_parameters)
continue;
TypeSpec type = invoke_pd.Types [i];
if (tic != null)
type = tic.InflateGenericArgument (ec, type);
if (!TypeSpecComparer.IsEqual (type, Parameters.Types [i])) {
if (ignore_errors)
return false;
ec.Report.Error (1678, Parameters [i].Location, "Parameter `{0}' is declared as type `{1}' but should be `{2}'",
(i+1).ToString (),
Parameters.Types [i].GetSignatureForError (),
invoke_pd.Types [i].GetSignatureForError ());
error = true;
}
}
return !error;
}
示例2: ResolveParameters
protected override ParametersCompiled ResolveParameters (ResolveContext ec, TypeInferenceContext tic, TypeSpec delegateType)
{
if (!delegateType.IsDelegate)
return null;
AParametersCollection d_params = Delegate.GetParameters (delegateType);
if (HasExplicitParameters) {
if (!VerifyExplicitParameters (ec, tic, delegateType, d_params))
return null;
return Parameters;
}
//
// If L has an implicitly typed parameter list we make implicit parameters explicit
// Set each parameter of L is given the type of the corresponding parameter in D
//
if (!VerifyParameterCompatibility (ec, tic, delegateType, d_params, ec.IsInProbingMode))
return null;
TypeSpec [] ptypes = new TypeSpec [Parameters.Count];
for (int i = 0; i < d_params.Count; i++) {
// D has no ref or out parameters
if ((d_params.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != 0)
return null;
TypeSpec d_param = d_params.Types [i];
//
// When type inference context exists try to apply inferred type arguments
//
if (tic != null) {
d_param = tic.InflateGenericArgument (ec, d_param);
}
ptypes [i] = d_param;
ImplicitLambdaParameter ilp = (ImplicitLambdaParameter) Parameters.FixedParameters [i];
ilp.SetParameterType (d_param);
ilp.Resolve (null, i);
}
Parameters.Types = ptypes;
return Parameters;
}
示例3: ResolveParameters
protected override ParametersCompiled ResolveParameters (ResolveContext ec, TypeInferenceContext tic, Type delegateType)
{
if (!TypeManager.IsDelegateType (delegateType))
return null;
AParametersCollection d_params = TypeManager.GetDelegateParameters (ec, delegateType);
if (HasExplicitParameters) {
if (!VerifyExplicitParameters (ec, delegateType, d_params))
return null;
return Parameters;
}
//
// If L has an implicitly typed parameter list we make implicit parameters explicit
// Set each parameter of L is given the type of the corresponding parameter in D
//
if (!VerifyParameterCompatibility (ec, delegateType, d_params, ec.IsInProbingMode))
return null;
Type [] ptypes = new Type [Parameters.Count];
for (int i = 0; i < d_params.Count; i++) {
// D has no ref or out parameters
if ((d_params.FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) != 0)
return null;
Type d_param = d_params.Types [i];
#if MS_COMPATIBLE
// Blablabla, because reflection does not work with dynamic types
if (d_param.IsGenericParameter)
d_param = delegateType.GetGenericArguments () [d_param.GenericParameterPosition];
#endif
//
// When type inference context exists try to apply inferred type arguments
//
if (tic != null) {
d_param = tic.InflateGenericArgument (d_param);
}
ptypes [i] = d_param;
((ImplicitLambdaParameter) Parameters.FixedParameters [i]).Type = d_param;
}
Parameters.Types = ptypes;
return Parameters;
}