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


C# ParameterInfo.Select方法代码示例

本文整理汇总了C#中System.Reflection.ParameterInfo.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.Select方法的具体用法?C# ParameterInfo.Select怎么用?C# ParameterInfo.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.ParameterInfo的用法示例。


在下文中一共展示了ParameterInfo.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildParameters

		//public string TypeName
		//{
		//	get { return TypeUtils.ToDisplayString(Parameter.ParameterType, true); }
		//}

		public static ParameterDom[] BuildParameters(ParameterInfo[] piAr, XElement parentDoc)
		{
			if(piAr==null || piAr.Length==0)
				return new ParameterDom[0];
			if(parentDoc==null)
				return piAr.Select(_ => new ParameterDom(_)).ToArray();

			var pd = new ParameterDictionary(parentDoc, "param");
			return piAr
				.Select( _ => new ParameterDom(_){DocInfo = pd[_.Name]})
				.ToArray();
		}
开发者ID:RakotVT,项目名称:StockSharp,代码行数:17,代码来源:ParameterDom.cs

示例2: AddMethod

        private void AddMethod(MethodInfo info, CodeTypeDeclaration target)
        {
            var method = new CodeMemberMethod
                         {
                             Attributes = MemberAttributes.Public,
                             Name = info.Name,
                             ReturnType = new CodeTypeReference(info.ReturnType),
                         };

            var allParameters = info.GetParameters().ToArray();

            var parameters = new ParameterInfo[0];
            if (allParameters.Length > 1)
                parameters = allParameters.Skip(1).ToArray();

            method.Parameters.AddRange(
                parameters.Select(p => new CodeParameterDeclarationExpression(p.ParameterType, p.Name)).ToArray());

            //Invoke
            var statement = new CodeMethodReturnStatement();

            string parms = GetInvokeParametersString(parameters);

            statement.Expression = new CodeSnippetExpression(string.Format("Invoke(d => d.{0}({1}))", info.Name, parms));

            method.Statements.Add(statement);

            target.Members.Add(method);
        }
开发者ID:ChrisASearles,项目名称:Infusionsoft.net,代码行数:29,代码来源:ServiceWrapperGenerator.cs

示例3: CreateConstructorParamtersInstances

 internal static object[] CreateConstructorParamtersInstances(this IoC ioc, ParameterInfo[] src)
 {
     return src
         .Select(pi => pi.IocParameterIsArray()
             ? ioc.GetParameterAsArray(pi.GetIocRealType())
             : ioc.GetObject(pi.ParameterType)).ToArray();
 }
开发者ID:amigin,项目名称:Flikr-test-assesment,代码行数:7,代码来源:IocUtils.cs

示例4: ConstructorHasAllMethodArgs

        private bool ConstructorHasAllMethodArgs(ParameterInfo[] methodArgs, ParameterInfo[] constructorParams)
        {
            var consArgTypes = constructorParams.Select(a => a.ParameterType).ToList();
            var methodArgTypes = methodArgs.Select(a => a.ParameterType).ToList();

            return !consArgTypes.Except(methodArgTypes).Any() &&
                !methodArgTypes.Except(consArgTypes).Any();
        }
开发者ID:DivineInject,项目名称:DivineInject,代码行数:8,代码来源:FactoryMethodFactory.cs

示例5: ValidateParameters

        private void ValidateParameters(ParameterInfo[] parameters, object[] parameterValues)
        {
            if (parameters.Length == parameterValues.Length && ParameterTypesMatch(parameters, parameterValues)) return;

            var expectedShape = CreateShape(parameters.Select(x => x.ParameterType));
            var actualShape = CreateShape(parameterValues.Select((x, index) => x == null ? parameters[index].ParameterType : x.GetType()));

            throw new InvalidParadigmExemplarException(string.Format("Invalid paradigm exemplar: expected it to have a shape of {0}, but it had a shape of {1}", expectedShape, actualShape));
        }
开发者ID:fulviogabana,项目名称:xUnit.Paradigms,代码行数:9,代码来源:ParadigmExemplar.cs

示例6: GetParameterValues

 private static object[] GetParameterValues(TestContext context, ParameterInfo[] parameters)
 {
     Func<ParameterInfo, int, object> selectFunc =
         (parameter, index) =>
         {
             context.WriteLine("{0} = {1}", parameter.Name, context.DataRow[index]);
             return context.DataRow[index];
         };
     return parameters.Select(selectFunc).ToArray();
 }
开发者ID:jeremybeavon,项目名称:MSTestCaseExtensions,代码行数:10,代码来源:ProvidesTestCasesAttribute.cs

示例7: CreateParameterExpressions

 private static Expression[] CreateParameterExpressions(ParameterInfo[] methodParams, ParameterExpression argsParameter)
 {
     return methodParams.Select(
         (parameter, index) =>
         Expression.Convert(
             Expression.ArrayIndex(argsParameter, Expression.Constant(index)),
             parameter.ParameterType
         )
     ).ToArray();
 }
开发者ID:JonasSyrstad,项目名称:Stardust,代码行数:10,代码来源:ObjectFactory.cs

示例8: CreateTypeName

        private static string CreateTypeName(string delegateName, ParameterInfo[] parameters)
        {
            var builder = new StringBuilder();

            builder.Append(delegateName);
            builder.Append("<");
            builder.Append(String.Join(",", parameters.Select(c => c.Name).ToArray()));
            builder.Append(">");

            return builder.ToString();
        }
开发者ID:samcook,项目名称:Fickle,代码行数:11,代码来源:FickleDelegateType.cs

示例9: GetCallMethodAsyncFuncInternal

        private static Delegate GetCallMethodAsyncFuncInternal(Type serviceType, Type argumentType, ParameterInfo[] arguments, MethodInfo method, bool hasReturn)
        {
            if (arguments.Length > 0 && argumentType == null)
                throw new ArgumentException("parameterType can not be null when paras.Length > 0");

            var serviceArgument = Expression.Parameter(typeof(object), "service");
            var actionArgument = Expression.Parameter(typeof(object), "argument");
            var asyncCallbackArgument = Expression.Parameter(typeof(AsyncCallback), "callback");
            var stateArgument = Expression.Parameter(typeof(object), "state");

            var convertService = Expression.Convert(serviceArgument, serviceType);
            var convertArgument = argumentType == null ? null : Expression.Convert(actionArgument, argumentType);

            MethodCallExpression call;
            if (arguments.Length > 1)
            {
                if (convertArgument == null)
                    throw new ArgumentException("argumentType can't be null when arguments.Length > 1");

                var callArgs = arguments
                    .Select(it => (Expression)Expression.Property(convertArgument, it.Name))
                    .ToList();

                callArgs.Add(asyncCallbackArgument);
                callArgs.Add(stateArgument);

                call = Expression.Call(convertService, method, callArgs);
            }
            else if (arguments.Length == 1)
            {
                call = Expression.Call(convertService, method, new Expression[] { convertArgument, asyncCallbackArgument, stateArgument });
            }
            else
            {
                call = Expression.Call(convertService, method, new Expression[] { asyncCallbackArgument, stateArgument });
            }

            var methodArgs = new[] { serviceArgument, actionArgument, asyncCallbackArgument, stateArgument };

            LambdaExpression methodLam;
            if (hasReturn)
            {
                var convertCall = Expression.Convert(call, typeof(IAsyncResult));
                methodLam = Expression.Lambda(convertCall, methodArgs);
            }
            else
            {
                methodLam = Expression.Lambda(call, methodArgs);
            }

            var methodFunc = methodLam.Compile();
            return methodFunc;
        }
开发者ID:chrishaly,项目名称:RpcLite,代码行数:53,代码来源:MethodHelper.cs

示例10: HasParameterSignature

 /// <summary>
 /// Compares the signature of the method with the given parameter types and returns true if
 /// all method parameters have the same order and type. Parameter names are not considered.
 /// </summary>
 /// <returns>True if the supplied parameter type array matches the method parameters array, false otherwise.</returns>
 public static bool HasParameterSignature(this MethodBase method, ParameterInfo[] parameters)
 {
     return method.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameters.Select(p => p.ParameterType));
 }
开发者ID:devworker55,项目名称:Mammatus,代码行数:9,代码来源:MethodInfoExtensions.cs

示例11: GetParameterData

 private object[] GetParameterData(ParameterInfo[] parameters, Fixture fixture)
 {
     return parameters
         .Select(p => new SpecimenContext(fixture).Resolve(p))
         .ToArray();
 }
开发者ID:jvandertil,项目名称:MembershipReboot.Postgres,代码行数:6,代码来源:NestedClassPerMethodConvention.cs

示例12: FormatParameters

 private static string FormatParameters(ParameterInfo[] parameters)
 {
     return string.Join(",", parameters.Select(x => x.ParameterType.Name));
 }
开发者ID:mediamonks,项目名称:IdentityServer3,代码行数:4,代码来源:ClassVisibilityTests.cs

示例13: SetSignature

		private void SetSignature(Type returnType, ParameterInfo returnParameter, Type[] parameters,
		                          ParameterInfo[] baseMethodParameters)
		{
			builder.SetSignature(
				returnType,
#if FEATURE_EMIT_CUSTOMMODIFIERS
				returnParameter.GetRequiredCustomModifiers(),
				returnParameter.GetOptionalCustomModifiers(),
#else
				null,
				null,
#endif
				parameters,
#if FEATURE_EMIT_CUSTOMMODIFIERS
				baseMethodParameters.Select(x => x.GetRequiredCustomModifiers()).ToArray(),
				baseMethodParameters.Select(x => x.GetOptionalCustomModifiers()).ToArray()
#else
				null,
				null
#endif
			);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:22,代码来源:MethodEmitter.cs

示例14: IdentifierImpl

 public IdentifierImpl(string className, string methodName, ParameterInfo[] parameters)
     : this(className, methodName, parameters.Select(p => p.Name).ToArray(), ToParameterStringArray(parameters.Select(p => p.ParameterType).ToArray()), false) {}
开发者ID:radi4music,项目名称:NakedObjectsFramework,代码行数:2,代码来源:IdentifierImpl.cs

示例15: BuildParameterList

 private List<Parameter> BuildParameterList(ParameterInfo[] parameters, bool checkForExtensionMethods)
 {
     if (parameters == null || parameters.Length == 0)
         return null;
     return parameters.Select(a => new Parameter
     {
         Name = a.Name,
         TypeName = GetReadableTypeName(a.ParameterType),
         ParameterFlags = GetParameterFlags(a, checkForExtensionMethods)
     }).ToList();
 }
开发者ID:codaxy,项目名称:dox,代码行数:11,代码来源:XmlCommentsDoxProviderImpl.cs


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