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


C# Type.FindMembers方法代码示例

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


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

示例1: FindMethod

        //CONFORMING
        private static MethodInfo FindMethod(Type type, string methodName, Type[] typeArgs, Expression[] args, BindingFlags flags) {
            MemberInfo[] members = type.FindMembers(MemberTypes.Method, flags, Type.FilterNameIgnoreCase, methodName);
            if (members == null || members.Length == 0)
                throw Error.MethodDoesNotExistOnType(methodName, type);

            MethodInfo method;

            var methodInfos = members.Map(t => (MethodInfo)t);
            int count = FindBestMethod(methodInfos, typeArgs, args, out method);

            if (count == 0)
                throw Error.MethodWithArgsDoesNotExistOnType(methodName, type);
            if (count > 1)
                throw Error.MethodWithMoreThanOneMatch(methodName, type);
            return method;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:17,代码来源:MethodCallExpression.cs

示例2: FindProperty

        private static PropertyInfo FindProperty(Type type, string propertyName, Expression[] arguments, BindingFlags flags) {
            MemberInfo[] members = type.FindMembers(MemberTypes.Property, flags, Type.FilterNameIgnoreCase, propertyName);
            if (members == null || members.Length == 0)
                return null;

            PropertyInfo pi;
            var propertyInfos = members.Map(t => (PropertyInfo)t);
            int count = FindBestProperty(propertyInfos, arguments, out pi);

            if (count == 0)
                return null;
            if (count > 1)
                throw Error.PropertyWithMoreThanOneMatch(propertyName, type);
            return pi;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:15,代码来源:IndexExpression.cs

示例3: ParseEnum

		private static object ParseEnum(string name, Type type)
		{
			if (type.IsEnum)
			{
				MemberInfo[] memberInfos = type.FindMembers(MemberTypes.Field,
				                                            BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static,
				                                            Type.FilterNameIgnoreCase, name);
				if (memberInfos.Length != 0) return ((FieldInfo) memberInfos[0]).GetValue(null);
			}
			return null;
		}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:11,代码来源:Dynamic.cs

示例4: ParseEnum

        static object ParseEnum(string name, Type type)
        {
#if !(NETFX_CORE || DNXCORE50)
            if (type.IsEnum)
            {
                MemberInfo[] memberInfos = type.FindMembers(MemberTypes.Field,
                    BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static,
                    Type.FilterNameIgnoreCase, name);
                if (memberInfos.Length != 0) return ((FieldInfo)memberInfos[0]).GetValue(null);
            }
#else
                    if (type.IsEnum())
                    {
                        return Enum.Parse(type, name, true);
                    }
#endif
            return null;
        }
开发者ID:StefH,项目名称:System.Linq.Dynamic,代码行数:18,代码来源:ExpressionParser.cs


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