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


C# IReflect.GetMethod方法代码示例

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


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

示例1: Bind

        static  Func<string, object> Bind(IReflect factory)
        {
            var method = factory.GetMethod("GetGrain", 
                BindingFlags.Public | BindingFlags.Static, null, 
                new[]{typeof(long), typeof(string)}, null);

            var argument = Expression.Parameter(typeof(string), "ext");
            var call = Expression.Call(method, new Expression[]{Expression.Constant(0L), argument});
            var lambda = Expression.Lambda<Func<string, object>>(call, argument);

            return lambda.Compile();
        }
开发者ID:hambroz,项目名称:Orleans.Bus,代码行数:12,代码来源:DynamicGrainFactory.cs

示例2: GetAndWrapMember

 private static MemberInfo[] GetAndWrapMember(IReflect reflect, Object namedItem, String name, BindingFlags bindingAttr){
   PropertyInfo property = reflect.GetProperty(name, bindingAttr);
   if (property != null){
     MethodInfo getMethod = JSProperty.GetGetMethod(property, false);
     MethodInfo setMethod = JSProperty.GetSetMethod(property, false);
     if ((getMethod != null && !getMethod.IsStatic) || (setMethod != null && !setMethod.IsStatic)){
       MethodInfo method = reflect.GetMethod(name, bindingAttr);
       if (method != null && !method.IsStatic){
         MemberInfo[] propMethods = new MemberInfo[1];
         propMethods[0] = new JSWrappedPropertyAndMethod(property, method, namedItem);
         return propMethods;
       }
     }
   }
   MemberInfo[] members = reflect.GetMember(name, bindingAttr);
   if (members != null && members.Length > 0)
     return ScriptObject.WrapMembers(members, namedItem);
   return null;
 }
开发者ID:ArildF,项目名称:masters,代码行数:19,代码来源:vsanameditemscope.cs

示例3: GetAndWrapMember

 private static MemberInfo[] GetAndWrapMember(IReflect reflect, object namedItem, string name, BindingFlags bindingAttr)
 {
     PropertyInfo property = reflect.GetProperty(name, bindingAttr);
     if (property != null)
     {
         MethodInfo getMethod = JSProperty.GetGetMethod(property, false);
         MethodInfo setMethod = JSProperty.GetSetMethod(property, false);
         if (((getMethod != null) && !getMethod.IsStatic) || ((setMethod != null) && !setMethod.IsStatic))
         {
             MethodInfo method = reflect.GetMethod(name, bindingAttr);
             if ((method != null) && !method.IsStatic)
             {
                 return new MemberInfo[] { new JSWrappedPropertyAndMethod(property, method, namedItem) };
             }
         }
     }
     MemberInfo[] member = reflect.GetMember(name, bindingAttr);
     if ((member != null) && (member.Length > 0))
     {
         return ScriptObject.WrapMembers(member, namedItem);
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:VsaNamedItemScope.cs

示例4: GetMethodExtended

       private static object GetMethodExtended(
 IReflect type,
 string name,
 bool staticMethod,
 int parameterCount)
       {
           var haveMethodName = false;
             BindingFlags flags = (staticMethod ? BindingFlags.Static :
           BindingFlags.Instance) | BindingFlags.Public |
           BindingFlags.NonPublic | BindingFlags.InvokeMethod;
             foreach (var method in type.GetMethods(flags)) {
           if (method.Name.Equals(name)) {
             haveMethodName = true;
             if (method.GetParameters().Length == parameterCount) {
           return method;
             }
           }
             }
             return haveMethodName ? type.GetMethod(name, flags) : null;
       }
开发者ID:peteroupc,项目名称:CBOR,代码行数:20,代码来源:Reflect.cs

示例5: RunMethod

        /// <summary>
        /// Runs the method.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="strMethod">The STR method.</param>
        /// <param name="objInstance">The obj instance.</param>
        /// <param name="objParams">The obj params.</param>
        /// <param name="eFlags">The e flags.</param>
        /// <returns></returns>
        private static object RunMethod(IReflect type, string strMethod, object objInstance, object [] objParams, BindingFlags eFlags)
        {
            MethodInfo method;
            try
            {
                if ((eFlags == InstanceBindingFlags) && (objInstance == null))
                {
                    throw new ArgumentException("The reflection non-static object argument was invalid");
                }
                if ((eFlags == StaticBindingFlags) && (objInstance != null))
                {
                    throw new ArgumentException("The reflection static object argument was invalid");
                }

                if ((objInstance != null) && (objInstance.GetType() != (Type)type) && (objInstance.GetType().BaseType != (Type)type))
                {
                    throw new ArgumentException("The object instance was of type '" + objInstance.GetType() + "' for type '" + type + "'.");
                }
                if (string.IsNullOrEmpty(strMethod))
                {
                    throw new ArgumentException("The reflection method argument was invalid");
                }
                method = type.GetMethod(strMethod, eFlags);
                if (method == null)
                {
                    throw new ArgumentException("There is no method '" + strMethod + "' for type '" + type + "'.");
                }

                var objRet = method.Invoke(objInstance, objParams);
                return objRet;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
开发者ID:Guzikowski,项目名称:TestMania,代码行数:46,代码来源:ReflectionTestHelper.cs

示例6: GetRegisteredEvents

 private static IEnumerable<Type> GetRegisteredEvents(IReflect proxyType, object proxy)
 {
     return (IEnumerable<Type>)proxyType
                                   .GetMethod("RegisteredEvents", BindingFlags.Instance | BindingFlags.NonPublic)
                                   .Invoke(proxy, new object[] { });
 }
开发者ID:Yitzchok,项目名称:Fohjin,代码行数:6,代码来源:IEventProvider.cs


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