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


C# MethodBase.GetParametersCached方法代码示例

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


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

示例1: Bind

        public static ParameterAssignment Bind(MethodBase method, string parameter, Expression expression)
        {
            // NB: This overload is needed for the compiler to emit factory calls;
            //     we can't emit a `ldtoken` instruction to obtain a ParameterInfo.

            ContractUtils.RequiresNotNull(method, nameof(method));
            ContractUtils.RequiresNotNull(parameter, nameof(parameter));

            var parameterInfo = default(ParameterInfo);

            foreach (var candidate in method.GetParametersCached())
            {
                if (candidate.Name == parameter)
                {
                    parameterInfo = candidate;
                    break;
                }
            }

            if (parameterInfo == null)
            {
                throw Error.ParameterNotDefinedForMethod(parameter, method.Name);
            }

            return Bind(parameterInfo, expression);
        }
开发者ID:taolin123,项目名称:ExpressionFutures,代码行数:26,代码来源:ParameterAssignment.cs

示例2: IsCompatible

 private static bool IsCompatible(MethodBase m, Expression[] args)
 {
     ParameterInfo[] parms = m.GetParametersCached();
     if (parms.Length != args.Length)
         return false;
     for (int i = 0; i < args.Length; i++)
     {
         Expression arg = args[i];
         ContractUtils.RequiresNotNull(arg, "argument");
         Type argType = arg.Type;
         Type pType = parms[i].ParameterType;
         if (pType.IsByRef)
         {
             pType = pType.GetElementType();
         }
         if (!TypeUtils.AreReferenceAssignable(pType, argType) &&
             !(TypeUtils.IsSameOrSubclass(typeof(LambdaExpression), pType) && pType.IsAssignableFrom(arg.GetType())))
         {
             return false;
         }
     }
     return true;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:23,代码来源:MethodCallExpression.cs

示例3: EmitArguments

        /// <summary>
        /// Emits arguments to a call, and returns an array of write-backs that
        /// should happen after the call. For emitting dynamic expressions, we
        /// need to skip the first parameter of the method (the call site).
        /// </summary>
        private List<WriteBack> EmitArguments(MethodBase method, IArgumentProvider args, int skipParameters)
        {
            ParameterInfo[] pis = method.GetParametersCached();
            Debug.Assert(args.ArgumentCount + skipParameters == pis.Length);

            var writeBacks = new List<WriteBack>();
            for (int i = skipParameters, n = pis.Length; i < n; i++)
            {
                ParameterInfo parameter = pis[i];
                Expression argument = args.GetArgument(i - skipParameters);
                Type type = parameter.ParameterType;

                if (type.IsByRef)
                {
                    type = type.GetElementType();

                    WriteBack wb = EmitAddressWriteBack(argument, type);
                    if (wb != null)
                    {
                        writeBacks.Add(wb);
                    }
                }
                else
                {
                    EmitExpression(argument);
                }
            }
            return writeBacks;
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:34,代码来源:LambdaCompiler.Expressions.cs

示例4: GetParametersForValidation

        private static ParameterInfo[] GetParametersForValidation(MethodBase method, ExpressionType nodeKind) {
            ParameterInfo[] pis = method.GetParametersCached();

            if (nodeKind == ExpressionType.Dynamic) {
                pis = pis.RemoveFirst(); // ignore CallSite argument
            }
            return pis;
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:MethodCallExpression.cs

示例5: MarkRefArgs

            /// <summary>
            /// Marks child expressions representing arguments bound to parameters of
            /// the specified <paramref name="method"/> as ByRef values if needed.
            /// </summary>
            /// <param name="method">
            /// The method containing the parameters bound to the arguments held by
            /// child expressions tracked by this rewriter.
            /// </param>
            /// <param name="startIndex">
            /// The index of the child expression representing the first argument. This
            /// value is typically 0 for static methods and 1 for instance methods.
            /// </param>
            internal void MarkRefArgs(MethodBase method, int startIndex)
            {
                var parameters = method.GetParametersCached();

                for (int i = 0, n = parameters.Length; i < n;  i++)
                {
                    if (parameters[i].ParameterType.IsByRef)
                    {
                        MarkRef(startIndex + i);
                    }
                }
            }
开发者ID:dotnet,项目名称:corefx,代码行数:24,代码来源:StackSpiller.ChildRewriter.cs

示例6: GetParameterBindings

 public static ReadOnlyCollection<ParameterAssignment> GetParameterBindings(MethodBase method, IEnumerable<Expression> expressions)
 {
     return GetParameterBindings(method.GetParametersCached(), expressions);
 }
开发者ID:taolin123,项目名称:ExpressionFutures,代码行数:4,代码来源:Helpers.cs

示例7: ValidateParameterBindings

 public static void ValidateParameterBindings(MethodBase method, ReadOnlyCollection<ParameterAssignment> argList, bool extensionMethod = false)
 {
     ValidateParameterBindings(method, method.GetParametersCached(), argList, extensionMethod);
 }
开发者ID:taolin123,项目名称:ExpressionFutures,代码行数:4,代码来源:Helpers.cs


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