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


C# RuntimeType.GetMember方法代码示例

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


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

示例1: ResolveOverloadedMethod

        private void ResolveOverloadedMethod(RuntimeType t, string methodName, ArrayList argNames, ArrayList argValues)
        {
            System.Reflection.MethodBase base2;
            MemberInfo[] infoArray = t.GetMember(methodName, MemberTypes.Method, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
            int length = infoArray.Length;
            switch (length)
            {
                case 1:
                    this.MI = infoArray[0] as System.Reflection.MethodBase;
                    return;

                case 0:
                    return;

                default:
                    base2 = null;
                    for (int i = 0; i < length; i++)
                    {
                        System.Reflection.MethodBase base3 = infoArray[i] as System.Reflection.MethodBase;
                        ParameterInfo[] parameters = base3.GetParameters();
                        if (parameters.Length == argValues.Count)
                        {
                            bool flag = true;
                            for (int j = 0; j < parameters.Length; j++)
                            {
                                Type parameterType = parameters[j].ParameterType;
                                if (parameterType.IsByRef)
                                {
                                    parameterType = parameterType.GetElementType();
                                }
                                if (parameterType != argValues[j].GetType())
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                base2 = base3;
                                break;
                            }
                        }
                    }
                    break;
            }
            if (base2 == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
            }
            this.MI = base2;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:51,代码来源:MethodCall.cs

示例2: ResolveOverloadedMethod

        // This will find the right overloaded method if the argValues from soap have type information,
        // By default parameters will be of type string, this could lead to a wrong choice of methodbase.
        void ResolveOverloadedMethod(RuntimeType t, String methodName, ArrayList argNames, ArrayList argValues)
        {
            MemberInfo[] canidates = t.GetMember(methodName, MemberTypes.Method, MethodCall.LookupPublic);

            int canidatesCount = canidates.Length;

            if (canidatesCount == 1)
            {
                MI = canidates[0] as MethodBase;
                return;
            }
                

            if (canidatesCount == 0)
                return;

            MethodBase match = null;

            for (int i = 0; i < canidatesCount; i++)
            {
                MethodBase canidate = canidates[i] as MethodBase;

                ParameterInfo[] parameters = canidate.GetParameters();

                if (parameters.Length == argValues.Count)
                {
                    bool isMatch = true;
                    for (int j = 0; j < parameters.Length; j++)
                    {
                        Type parameterType = parameters[j].ParameterType;

                        if (parameterType.IsByRef)
                            parameterType = parameterType.GetElementType();

                        if (parameterType != argValues[j].GetType())
                        {
                            isMatch = false;
                            break;
                        }

                    }
                    if (isMatch)
                    {
                        match = canidate;
                        break;
                    }
                }
            }
            if (match == null)
                throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
            MI = match;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:54,代码来源:message.cs


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