本文整理汇总了C#中Mono.CSharp.AParametersCollection类的典型用法代码示例。如果您正苦于以下问题:C# AParametersCollection类的具体用法?C# AParametersCollection怎么用?C# AParametersCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AParametersCollection类属于Mono.CSharp命名空间,在下文中一共展示了AParametersCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDelegateType
public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
{
Namespace type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);
if (type_ns == null) {
return null;
}
if (returnType == rc.BuiltinTypes.Void) {
var actArgs = parameters.Types;
var actionSpec = type_ns.LookupType (rc.Module, "Action", actArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
if (actionSpec == null) {
return null;
}
if (actArgs.Length == 0)
return actionSpec;
else
return actionSpec.MakeGenericType(rc, actArgs);
} else {
TypeSpec[] funcArgs = new TypeSpec[parameters.Types.Length + 1];
parameters.Types.CopyTo(funcArgs, 0);
funcArgs[parameters.Types.Length] = returnType;
var funcSpec = type_ns.LookupType (rc.Module, "Func", funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
if (funcSpec == null)
return null;
return funcSpec.MakeGenericType(rc, funcArgs);
}
}
示例2: CreateDelegateType
public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
{
Namespace type_ns;
string paramsSuffix = "";
TypeSpec[] paramTypes = parameters.Types;
type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);
// Do we have a PARAMS argument as the final argument? (Only supported in PlayScript)
if (rc.FileType == SourceFileType.PlayScript && parameters.FixedParameters.Length > 0 &&
(parameters.FixedParameters [parameters.FixedParameters.Length - 1].ModFlags & Parameter.Modifier.PARAMS) != 0) {
paramsSuffix = "P";
TypeSpec[] newTypes = new TypeSpec[paramTypes.Length - 1];
Array.Copy (paramTypes, 0, newTypes, 0, newTypes.Length);
paramTypes = newTypes;
type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("PlayScript", true);
}
if (type_ns == null) {
return null;
}
if (returnType == rc.BuiltinTypes.Void) {
var actArgs = paramTypes;
var actionType = type_ns.LookupType (rc.Module, "Action" + paramsSuffix, actArgs.Length, LookupMode.Normal, loc);
if (actionType == null) {
return rc.BuiltinTypes.Delegate;
}
var actionSpec = actionType.ResolveAsType(rc);
if (actionSpec == null) {
return null;
}
if (actArgs.Length == 0)
return actionSpec;
else
return actionSpec.MakeGenericType(rc, actArgs);
} else {
TypeSpec[] funcArgs = new TypeSpec[paramTypes.Length + 1];
paramTypes.CopyTo(funcArgs, 0);
funcArgs[paramTypes.Length] = returnType;
var funcSpec = type_ns.LookupType (rc.Module, "Func" + paramsSuffix, funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
if (funcSpec == null) {
return rc.BuiltinTypes.Delegate;
}
return funcSpec.MakeGenericType(rc, funcArgs);
}
}
示例3: GetApplicableParametersCount
protected override int GetApplicableParametersCount (MethodBase method, AParametersCollection parameters)
{
//
// Here is the trick, decrease number of arguments by 1 when only
// available property method is setter. This makes overload resolution
// work correctly for indexers.
//
if (method.Name [0] == 'g')
return parameters.Count;
return parameters.Count - 1;
}
示例4: VerifyExplicitParameters
protected bool VerifyExplicitParameters (ResolveContext ec, TypeSpec delegate_type, AParametersCollection parameters)
{
if (VerifyParameterCompatibility (ec, delegate_type, parameters, ec.IsInProbingMode))
return true;
if (!ec.IsInProbingMode)
ec.Report.Error (1661, loc,
"Cannot convert `{0}' to delegate type `{1}' since there is a parameter mismatch",
GetSignatureForError (), TypeManager.CSharpName (delegate_type));
return false;
}
示例5: IndexerSpec
public IndexerSpec (TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, AParametersCollection parameters, PropertyInfo info, Modifiers modifiers)
: base (MemberKind.Indexer, declaringType, definition, memberType, info, modifiers)
{
this.parameters = parameters;
}
示例6: AddParameter
public void AddParameter (MonoDevelop.Projects.Dom.AbstractMember member, AParametersCollection parameters)
{
for (int i = 0; i < parameters.Count; i++) {
var p = (Parameter)parameters.FixedParameters[i];
DomParameter parameter = new DomParameter ();
parameter.Name = ConvertQuoted (p.Name);
parameter.Location = Convert (p.Location);
parameter.ReturnType = ConvertReturnType (p.TypeExpression);
var modifiers = MonoDevelop.Projects.Dom.ParameterModifiers.None;
if ((p.ParameterModifier & Parameter.Modifier.OUT) == Parameter.Modifier.OUT)
modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.Out;
if ((p.ParameterModifier & Parameter.Modifier.REF) == Parameter.Modifier.REF)
modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.Ref;
if ((p.ParameterModifier & Parameter.Modifier.PARAMS) == Parameter.Modifier.PARAMS)
modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.Params;
if ((p.ParameterModifier & Parameter.Modifier.This) == Parameter.Modifier.This)
modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.This;
parameter.ParameterModifiers = modifiers;
member.Add (parameter);
}
}
示例7: ImportedGenericMethodDefinition
public ImportedGenericMethodDefinition (MethodInfo provider, TypeSpec type, AParametersCollection parameters, TypeParameterSpec[] tparams, MetadataImporter importer)
: base (provider, type, parameters, importer)
{
this.tparams = tparams;
}
示例8: 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;
}
示例9: ImportedGenericMethodDefinition
public ImportedGenericMethodDefinition (MethodInfo provider, AParametersCollection parameters, TypeParameterSpec[] tparams)
: base (provider, parameters)
{
this.tparams = tparams;
}
示例10: AreOverloadedMethodParamsClsCompliant
/// <summary>
/// Returns true if parameters of two compared methods are CLS-Compliant.
/// It tests differing only in ref or out, or in array rank.
/// </summary>
public static Result AreOverloadedMethodParamsClsCompliant (AParametersCollection pa, AParametersCollection pb)
{
TypeSpec [] types_a = pa.Types;
TypeSpec [] types_b = pb.Types;
if (types_a == null || types_b == null)
return Result.Ok;
if (types_a.Length != types_b.Length)
return Result.Ok;
Result result = Result.Ok;
for (int i = 0; i < types_b.Length; ++i) {
TypeSpec aType = types_a [i];
TypeSpec bType = types_b [i];
var ac_a = aType as ArrayContainer;
var ac_b = aType as ArrayContainer;
if (ac_a != null && ac_b != null) {
if (ac_a.Rank != ac_b.Rank && ac_a.Element == ac_b.Element) {
result = Result.RefOutArrayError;
continue;
}
if (ac_a.Element.IsArray || ac_b.Element.IsArray) {
result = Result.ArrayArrayError;
continue;
}
}
if (aType != bType)
return Result.Ok;
const Parameter.Modifier out_ref_mod = (Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
if ((pa.FixedParameters[i].ModFlags & out_ref_mod) != (pb.FixedParameters[i].ModFlags & out_ref_mod))
result = Result.RefOutArrayError;
}
return result;
}
示例11: ParametersImported
ParametersImported (AParametersCollection param, TypeSpec[] types)
{
this.parameters = param.FixedParameters;
this.types = types;
has_arglist = param.HasArglist;
has_params = param.HasParams;
}
示例12: GetApplicableParametersCount
protected virtual int GetApplicableParametersCount(MethodSpec method, AParametersCollection parameters)
{
return parameters.Count;
}
示例13: Error_InvalidArguments
protected virtual void Error_InvalidArguments(ResolveContext ec, Location loc, int idx, MethodSpec method,
Argument a, AParametersCollection expected_par, TypeSpec paramType)
{
ExtensionMethodGroupExpr emg = this as ExtensionMethodGroupExpr;
if (a is CollectionElementInitializer.ElementInitializerArgument) {
ec.Report.SymbolRelatedToPreviousError (method);
if ((expected_par.FixedParameters [idx].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
ec.Report.Error (1954, loc, "The best overloaded collection initalizer method `{0}' cannot have 'ref', or `out' modifier",
TypeManager.CSharpSignature (method));
return;
}
ec.Report.Error (1950, loc, "The best overloaded collection initalizer method `{0}' has some invalid arguments",
TypeManager.CSharpSignature (method));
} else if (TypeManager.IsDelegateType (method.DeclaringType)) {
ec.Report.Error (1594, loc, "Delegate `{0}' has some invalid arguments",
TypeManager.CSharpName (method.DeclaringType));
} else {
ec.Report.SymbolRelatedToPreviousError (method);
if (emg != null) {
ec.Report.Error (1928, loc,
"Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' has some invalid arguments",
emg.ExtensionExpression.GetSignatureForError (),
emg.Name, TypeManager.CSharpSignature (method));
} else {
ec.Report.Error (1502, loc, "The best overloaded method match for `{0}' has some invalid arguments",
TypeManager.CSharpSignature (method));
}
}
Parameter.Modifier mod = idx >= expected_par.Count ? 0 : expected_par.FixedParameters [idx].ModFlags;
string index = (idx + 1).ToString ();
if (((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) ^
(a.Modifier & (Parameter.Modifier.REF | Parameter.Modifier.OUT))) != 0) {
if ((mod & Parameter.Modifier.ISBYREF) == 0)
ec.Report.Error (1615, loc, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier",
index, Parameter.GetModifierSignature (a.Modifier));
else
ec.Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier",
index, Parameter.GetModifierSignature (mod));
} else {
string p1 = a.GetSignatureForError ();
string p2 = TypeManager.CSharpName (paramType);
if (p1 == p2) {
ec.Report.ExtraInformation (loc, "(equally named types possibly from different assemblies in previous ");
ec.Report.SymbolRelatedToPreviousError (a.Expr.Type);
ec.Report.SymbolRelatedToPreviousError (paramType);
}
if (idx == 0 && emg != null) {
ec.Report.Error (1929, loc,
"Extension method instance type `{0}' cannot be converted to `{1}'", p1, p2);
} else {
ec.Report.Error (1503, loc,
"Argument `#{0}' cannot convert `{1}' expression to type `{2}'", index, p1, p2);
}
}
}
示例14: Create
//
// Generic method parameters importer, param is shared between all instances
//
public static AParametersCollection Create (AParametersCollection param, MethodBase method)
{
if (param.IsEmpty)
return param;
ParameterInfo [] pi = method.GetParameters ();
Type [] types = new Type [pi.Length];
for (int i = 0; i < types.Length; i++) {
Type t = pi [i].ParameterType;
if (t.IsByRef)
t = TypeManager.GetElementType (t);
types [i] = TypeManager.TypeToCoreType (t);
}
return new ParametersCollection (param, types);
}
示例15: AreOverloadedMethodParamsClsCompliant
/// <summary>
/// Returns true if parameters of two compared methods are CLS-Compliant.
/// It tests differing only in ref or out, or in array rank.
/// </summary>
public static Result AreOverloadedMethodParamsClsCompliant (AParametersCollection pa, AParametersCollection pb)
{
Type [] types_a = pa.Types;
Type [] types_b = pb.Types;
if (types_a == null || types_b == null)
return Result.Ok;
if (types_a.Length != types_b.Length)
return Result.Ok;
Result result = Result.Ok;
for (int i = 0; i < types_b.Length; ++i) {
Type aType = types_a [i];
Type bType = types_b [i];
if (aType.IsArray && bType.IsArray) {
Type a_el_type = TypeManager.GetElementType (aType);
Type b_el_type = TypeManager.GetElementType (bType);
if (aType.GetArrayRank () != bType.GetArrayRank () && a_el_type == b_el_type) {
result = Result.RefOutArrayError;
continue;
}
if (a_el_type.IsArray || b_el_type.IsArray) {
result = Result.ArrayArrayError;
continue;
}
}
if (aType != bType)
return Result.Ok;
const Parameter.Modifier out_ref_mod = (Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
if ((pa.FixedParameters[i].ModFlags & out_ref_mod) != (pb.FixedParameters[i].ModFlags & out_ref_mod))
result = Result.RefOutArrayError;
}
return result;
}