本文整理汇总了C#中CallSignature.GetArgumentKind方法的典型用法代码示例。如果您正苦于以下问题:C# CallSignature.GetArgumentKind方法的具体用法?C# CallSignature.GetArgumentKind怎么用?C# CallSignature.GetArgumentKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CallSignature
的用法示例。
在下文中一共展示了CallSignature.GetArgumentKind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeCheckSelf
private Expression/*!*/ MakeCheckSelf(DynamicMetaObjectBinder/*!*/ binder, CallSignature signature, DynamicMetaObject/*!*/[]/*!*/ args) {
ArgumentType firstArgKind = signature.GetArgumentKind(0);
Expression res;
if (firstArgKind == ArgumentType.Simple || firstArgKind == ArgumentType.Instance) {
res = CheckSelf(binder, AstUtils.Convert(Expression, typeof(Method)), args[0].Expression);
} else if (firstArgKind != ArgumentType.List) {
res = CheckSelf(binder, AstUtils.Convert(Expression, typeof(Method)), AstUtils.Constant(null));
} else {
// list, check arg[0] and then return original list. If not a list,
// or we have no items, then check against null & throw.
res = CheckSelf(
binder,
AstUtils.Convert(Expression, typeof(Method)),
Ast.Condition(
Ast.AndAlso(
Ast.TypeIs(args[0].Expression, typeof(IList<object>)),
Ast.NotEqual(
Ast.Property(
Ast.Convert(args[0].Expression, typeof(ICollection)),
typeof(ICollection).GetProperty("Count")
),
AstUtils.Constant(0)
)
),
Ast.Call(
Ast.Convert(args[0].Expression, typeof(IList<object>)),
typeof(IList<object>).GetMethod("get_Item"),
AstUtils.Constant(0)
),
AstUtils.Constant(null)
)
);
}
return res;
}
示例2: GetArgumentTypes
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")] // TODO: fix
private static DynamicMetaObject[] GetArgumentTypes(CallSignature signature, IList<DynamicMetaObject> args) {
List<DynamicMetaObject> res = new List<DynamicMetaObject>();
List<DynamicMetaObject> namedObjects = null;
for (int i = 0; i < args.Count; i++) {
switch (signature.GetArgumentKind(i)) {
case ArgumentType.Named:
if (namedObjects == null) {
namedObjects = new List<DynamicMetaObject>();
}
namedObjects.Add(args[i]);
break;
case ArgumentType.Simple:
case ArgumentType.Instance:
res.Add(args[i]);
break;
case ArgumentType.List:
IList<object> list = args[i].Value as IList<object>;
if (list == null) return null;
for (int j = 0; j < list.Count; j++) {
res.Add(
new DynamicMetaObject(
Ast.Call(
Ast.Convert(
args[i].Expression,
typeof(IList<object>)
),
typeof(IList<object>).GetMethod("get_Item"),
Ast.Constant(j)
),
args[i].Restrictions,
list[j]
)
);
}
break;
case ArgumentType.Dictionary:
// caller needs to process these...
break;
default:
throw new NotImplementedException();
}
}
if (namedObjects != null) {
res.AddRange(namedObjects);
}
return res.ToArray();
}