本文整理汇总了C#中System.Reflection.ParameterInfo.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.Skip方法的具体用法?C# ParameterInfo.Skip怎么用?C# ParameterInfo.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.Skip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapArgumentsByPosition
private void MapArgumentsByPosition(Route source, ParameterInfo[] requiredArguments, NameValueCollection headers, int skipNumberOfDestinationArguments, List<KeyValuePair<Type, ParameterNameAndLocation>> map)
{
if ((requiredArguments.Length - skipNumberOfDestinationArguments) != source.QueryParameters.Count() + source.RouteParameters.Count())
throw new InvalidOperationException("Either use parameter names mathing the query and route parameters or specify as many parameters as the combined number of route and query variables");
IEnumerator headerParameters = headers.AllKeys.GetEnumerator();
IEnumerator<string> routeParameters = source.RouteParameters.GetEnumerator();
IEnumerator<string> queryParameters = source.QueryParameters.GetEnumerator();
foreach (ParameterInfo argument in requiredArguments.Skip(skipNumberOfDestinationArguments))
{
if (headerParameters.MoveNext())
{
object value = RouteHelpers.GetHeaderParameterValue((string)headerParameters.Current, headers, argument.ParameterType);
if (value != null)
{
map.Add(new KeyValuePair<Type, ParameterNameAndLocation>(argument.ParameterType,
new ParameterNameAndLocation { Name = routeParameters.Current, Location = ParameterLocation.Header }));
}
}
if (routeParameters.MoveNext())
{
map.Add(new KeyValuePair<Type, ParameterNameAndLocation>(argument.ParameterType,
new ParameterNameAndLocation{ Name = routeParameters.Current, Location = ParameterLocation.Route }));
}
else
{
queryParameters.MoveNext();
map.Add(new KeyValuePair<Type, ParameterNameAndLocation>(argument.ParameterType,
new ParameterNameAndLocation{ Name = queryParameters.Current, Location = ParameterLocation.Query }));
}
}
}
示例2: GetParametersShortSignature
public static string GetParametersShortSignature(ParameterInfo[] pars, int skipCount = 0)
{
if (pars.Length < 1 + skipCount)
return "";
return "(" +
pars
.Skip(skipCount)
.Select(_ => TypeUtils.ToDisplayString(_.ParameterType, false))
.Aggregate((s1, s2) => s1 + ", " + s2)
+ ")";
}
示例3: GetParametersLongSignature
public static XElement GetParametersLongSignature(ParameterInfo[] pars, int skipCount = 0)
{
if (pars.Length < 1+skipCount)
return new XElement("span");
var args = pars
.Skip(skipCount)
.SelectMany(p => new[]
{
GenerateHtml.BuildTypeUrl(p.ParameterType, false),
new XElement("span", ","),
})
.ToArray();
return new XElement("span", new XElement("span", "("), args.Take(args.Count() - 1), new XElement("span", ")"));
}
示例4: CheckParameters
private static void CheckParameters(ICommandInfo commandInfo, ParameterInfo[] parameters)
{
if (parameters.Length < 1
|| parameters[0].ParameterType != typeof(ICommandContext))
throw new ApplicationException(
"Отсутствует первый параметр, имеющий тип ICommandContext.");
foreach (var methodParameter in parameters.Skip(1))
{
if (!commandInfo.IsParameterExists(methodParameter.Name))
throw new ApplicationException($"Параметр '{methodParameter.Name}' не предусмотрен командой.");
if (commandInfo.GetParameter(methodParameter.Name).IsOptional
&& methodParameter.ParameterType.IsValueType
&& methodParameter.ParameterType == typeof(Nullable<>))
throw new ApplicationException(
$"Необязательный параметр '{methodParameter.Name}' должен иметь ссылочный тип.");
}
}
示例5: TryWrappedInvokeOrInvokeMember
private bool TryWrappedInvokeOrInvokeMember(DynamicMetaObjectBinder binder, ParameterInfo[] parameters, object[] args, out object result)
{
Type[] paramTypes = null;
if ((parameters != null) && (parameters.Length >= args.Length))
{
paramTypes = parameters.Skip(parameters.Length - args.Length).Select(param => param.ParameterType).ToArray();
}
if (paramTypes != null)
{
for (var index = 0; index < paramTypes.Length; index++)
{
var paramType = paramTypes[index];
if (paramType.IsByRef)
{
args[index] = typeof(HostVariable<>).MakeSpecificType(paramType.GetElementType()).CreateInstance(args[index]);
}
}
}
if (TryWrappedBindAndInvoke(binder, AdjustInvokeArgs(args), out result))
{
if (paramTypes != null)
{
for (var index = 0; index < paramTypes.Length; index++)
{
if (paramTypes[index].IsByRef)
{
var hostVariable = args[index] as IHostVariable;
if (hostVariable != null)
{
args[index] = hostVariable.Value;
}
}
}
}
return true;
}
return false;
}
示例6: DefaultParamValues
void DefaultParamValues(List<Argument> arguments, ParameterInfo[] parameters)
{
var defaultArgs = parameters
.Skip(arguments.Count)
.Where(param => param.IsOptional)
.Select(param => new Argument(Expr.Constant(param.DefaultValue), param.ParameterType));
arguments.AddRange(defaultArgs);
}
示例7: DefaultParamTypeValues
void DefaultParamTypeValues(List<Argument> arguments, ParameterInfo[] parameters)
{
var typeDefaultArgs = parameters
.Skip(arguments.Count)
.Select(param => new Argument(Expr.Constant(param.ParameterType.GetDefaultValue()), param.ParameterType));
arguments.AddRange(typeDefaultArgs);
}
示例8: HelperGetParams
string HelperGetParams(ParameterInfo[] it)
{
var parms = it.Skip(1);
return String.Join(",", parms.Select(p => HelperFormatType(p.ParameterType) + " " + p.Name));
}