当前位置: 首页>>代码示例>>C#>>正文


C# ParameterInfo.Skip方法代码示例

本文整理汇总了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 }));
                }
            }
        }
开发者ID:ToshB,项目名称:nservicestub,代码行数:35,代码来源:MapRequestToDelegateHeuristic.cs

示例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)
			+ ")";
		}
开发者ID:iwhy,项目名称:StockSharp,代码行数:11,代码来源:MemberUtils.cs

示例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", ")"));
		}
开发者ID:iwhy,项目名称:StockSharp,代码行数:16,代码来源:MemberUtils.cs

示例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}' должен иметь ссылочный тип.");
			}
		}
开发者ID:rsdn,项目名称:janus,代码行数:18,代码来源:CommandTarget.cs

示例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;
        }
开发者ID:dirkelfman,项目名称:ClearScript,代码行数:42,代码来源:ScriptItem.cs

示例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);
        }
开发者ID:ericmj,项目名称:IronLua,代码行数:9,代码来源:LuaInvokeBinder.cs

示例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);
 }
开发者ID:ericmj,项目名称:IronLua,代码行数:7,代码来源:LuaInvokeBinder.cs

示例8: HelperGetParams

        string HelperGetParams(ParameterInfo[] it)
        {
            var parms = it.Skip(1);
            return String.Join(",", parms.Select(p => HelperFormatType(p.ParameterType) + " " + p.Name));

        }
开发者ID:bbenzikry,项目名称:impromptu-interface,代码行数:6,代码来源:Linq.cs


注:本文中的System.Reflection.ParameterInfo.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。