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


C# MethodInfo.ToString方法代码示例

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


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

示例1: AsTransactional

		public Maybe<ITransactionOptions> AsTransactional(MethodInfo target)
		{
			Contract.Requires(target != null);
			Contract.Ensures(Contract.Result<Maybe<TransactionAttribute>>() != null);
			return _TxMethodsHackMap.ContainsKey(target.ToString())
					? Maybe.Some<ITransactionOptions>(_TxMethodsHackMap[target.ToString()])
			       	: Maybe.None<ITransactionOptions>();
		}
开发者ID:andreabalducci,项目名称:Castle.Transactions,代码行数:8,代码来源:TransactionalClassMetaInfo.cs

示例2: MethodInfoToFtnptr

		private static IntPtr MethodInfoToFtnptr (MethodInfo method) {
			if (module_builder.Assembly.GetType ("BridgeHelpers" + method.ToString ()) != null)
				return (IntPtr) module_builder.Assembly.GetType ("BridgeHelpers" + method.ToString ()).InvokeMember ("InternalMethodInfoToFtnPtr", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public, null, null, new object[] { });

			TypeBuilder ftn_converter_builder = module_builder.DefineType ("BridgeHelpers" + method.ToString (), TypeAttributes.Public);
			MethodBuilder ftn_method = ftn_converter_builder.DefineMethod ("InternalMethodInfoToFtnPtr", MethodAttributes.Public | MethodAttributes.Static, typeof (IntPtr), new Type[] { }); 
			ILGenerator il_generator = ftn_method.GetILGenerator ();
			
			il_generator.Emit (OpCodes.Ldftn, method);
			il_generator.Emit (OpCodes.Ret);
			
			Type ftn_converter = ftn_converter_builder.CreateType ();
			return (IntPtr) ftn_converter.InvokeMember ("InternalMethodInfoToFtnPtr", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public, null, null, new object[] { });
		}
开发者ID:emtees,项目名称:old-code,代码行数:14,代码来源:Bridge.cs

示例3: MethodNode

 public MethodNode(object parentObj, MethodInfo m)
     : base(null, NodeTypes.Method, m.ToString())
 {
     parentObject = parentObj;
     method = m;
     CanInvoke = true;
 }
开发者ID:daxnet,项目名称:spotfire_dom_viewer,代码行数:7,代码来源:MethodNode.cs

示例4: executeXRuleMethod

 public static void executeXRuleMethod(MethodInfo methodToExecute, Action<bool,object> executionResult)
 {            
     if (methodToExecute == null)
     {                
         executionResult(false,null);
     }
     else
         try
         {
             DI.log.info("executing method: {0}", methodToExecute.Name);
             // create method's type using default constructor
             var liveObject = DI.reflection.createObjectUsingDefaultConstructor(methodToExecute.DeclaringType);
             // and execute the method
             var returnData = methodToExecute.Invoke(liveObject, new object[] { });            // don't use the DI.reflection methods since we want the exceptions to be thrown
             //DI.reflection.invoke(liveObject, methodInfo, new object[] {});
             executionResult(true, returnData);
         }
         catch (Exception ex)
         {
             DI.log.error("in UnitTestSupport.executeXRuleMethod: {0} threw error: {1} ", methodToExecute.ToString(),
                          ex.Message);
             if (ex.InnerException != null)
             {
                 var innerExceptionMessage = ex.InnerException.Message;
                 DI.log.error("   InnerException value: {0}", innerExceptionMessage);
                 executionResult(false, innerExceptionMessage);
             }
             else
                 executionResult(false, null);
         }
 }
开发者ID:o2platform,项目名称:O2.Platform.Projects.Misc_and_Legacy,代码行数:31,代码来源:UnitTestExecution.cs

示例5: GetAttribute

 internal static WebMethodAttribute GetAttribute(MethodInfo implementation, MethodInfo declaration)
 {
     WebMethodAttribute attribute = null;
     WebMethodAttribute attribute2 = null;
     object[] customAttributes;
     if (declaration != null)
     {
         customAttributes = declaration.GetCustomAttributes(typeof(WebMethodAttribute), false);
         if (customAttributes.Length > 0)
         {
             attribute = (WebMethodAttribute) customAttributes[0];
         }
     }
     customAttributes = implementation.GetCustomAttributes(typeof(WebMethodAttribute), false);
     if (customAttributes.Length > 0)
     {
         attribute2 = (WebMethodAttribute) customAttributes[0];
     }
     if (attribute == null)
     {
         return attribute2;
     }
     if (attribute2 == null)
     {
         return attribute;
     }
     if (attribute2.MessageNameSpecified)
     {
         throw new InvalidOperationException(Res.GetString("ContractOverride", new object[] { implementation.Name, implementation.DeclaringType.FullName, declaration.DeclaringType.FullName, declaration.ToString(), "WebMethod.MessageName" }));
     }
     return new WebMethodAttribute(attribute2.EnableSessionSpecified ? attribute2.EnableSession : attribute.EnableSession) { TransactionOption = attribute2.TransactionOptionSpecified ? attribute2.TransactionOption : attribute.TransactionOption, CacheDuration = attribute2.CacheDurationSpecified ? attribute2.CacheDuration : attribute.CacheDuration, BufferResponse = attribute2.BufferResponseSpecified ? attribute2.BufferResponse : attribute.BufferResponse, Description = attribute2.DescriptionSpecified ? attribute2.Description : attribute.Description };
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:WebMethodReflector.cs

示例6: GetMethodGenerator

        public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
        {
            IHqlGeneratorForMethod methodGenerator;

            if (method.IsGenericMethod)
            {
                method = method.GetGenericMethodDefinition();
            }

            if (_registeredMethods.TryGetValue(method, out methodGenerator))
            {
                return methodGenerator;
            }

            // No method generator registered.  Look to see if it's a standard LinqExtensionMethod
            var attr = method.GetCustomAttributes(typeof (LinqExtensionMethodAttribute), false);
            if (attr.Length == 1)
            {
                // It is
                // TODO - cache this?  Is it worth it?
                return new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute) attr[0], method);
            }

            // Not that either.  Let's query each type generator to see if it can handle it
            foreach (var typeGenerator in _typeGenerators)
            {
                if (typeGenerator.SupportsMethod(method))
                {
                    return typeGenerator.GetMethodGenerator(method);
                }
            }

            throw new NotSupportedException(method.ToString());
        }
开发者ID:paulbatum,项目名称:nhibernate,代码行数:34,代码来源:FunctionRegistry.cs

示例7: Command

		protected Command(object target, MethodInfo mi)
			: base(target, mi)
		{
			ParameterInfo[] paramList = mi.GetParameters();

			_names = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
			List<Argument> tempList = new List<Argument>();

			foreach (ParameterInfo pi in paramList)
			{
				Argument arg = new Argument(target, pi);
				foreach(string name in arg.AllNames)
					_names.Add(name, tempList.Count);
				tempList.Add(arg);
			}
			_arguments = tempList.ToArray();

			if (base.Description == mi.ToString())
            {//if no description provided, let's build a better one
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("{0} ", base.DisplayName);
                foreach(Argument a in tempList)
					if(a.Visible)
						sb.AppendFormat("{0} ", a.FormatSyntax(a.DisplayName));
                _description = sb.ToString(0, sb.Length - 1);
            }
		}
开发者ID:modulexcite,项目名称:CSharpTest.Net.Tools,代码行数:27,代码来源:Command.cs

示例8: EmitCall

        public void EmitCall(OpCode opCode, MethodInfo mi)
        {
            ProcessCommand(
                opCode, 
                (mi.GetParameters().Length + 1) * -1 + (mi.ReturnType == typeof(void) ? 0 : 1), 
                mi.ToString()
                );

            ilGenerator.EmitCall(opCode, mi, null);
        }
开发者ID:antonovicha,项目名称:EmitMapperRedux,代码行数:10,代码来源:CompilationContext.cs

示例9: GetMethodGenerator

        public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
        {
            IHqlGeneratorForMethod methodGenerator;

            if (!TryGetMethodGenerator(method, out methodGenerator))
            {
                throw new NotSupportedException(method.ToString());
            }

            return methodGenerator;
        }
开发者ID:kkozmic,项目名称:nhibernate,代码行数:11,代码来源:FunctionRegistry.cs

示例10: GetParallelMethod

        private MethodInfo GetParallelMethod(MethodInfo forkMethod)
        {
            MethodInfo result = null;
            MethodInfo[] methods =
                source.GetMethods(BindingFlags.Instance | BindingFlags.Static |
                                  BindingFlags.Public | BindingFlags.NonPublic);
            foreach (MethodInfo method in methods)
                if (IsParallel(method)
                    && SignatureMatch(forkMethod, method))
                {
                    if (result == null)
                        result = method;
                    else
                        throw new InvalidMethodException(source.Name, forkMethod.ToString(),
                                                         "There is more than one parallel method which has a nonchannel parameter signature that matches this [Fork] method.");

                }

            if (result == null)
                throw new InvalidMethodException(source.Name, forkMethod.ToString(),
                                                 "There is no parallel method which has a nonchannel parameter signature that matches this [Fork] method.");

            return result;
        }
开发者ID:Noah1989,项目名称:fmacj,代码行数:24,代码来源:TypeAnalyzer.Fork.cs

示例11: getMethodDefinitionFromMethodInfo

 public static MethodDefinition getMethodDefinitionFromMethodInfo(MethodInfo methodInfo, Mono.Cecil.AssemblyDefinition assemblyDefinition)
 {
     foreach (var methodDefinition in CecilUtils.getMethods(assemblyDefinition))
     {
         var functionSignature1 = new FilteredSignature(methodInfo);
         var functionSignature2 = new FilteredSignature(methodDefinition.ToString());
         if (functionSignature1.sSignature == functionSignature2.sSignature)                
             return methodDefinition;
         if (functionSignature1.sFunctionName == functionSignature2.sFunctionName)
         { 
         }
     }
     PublicDI.log.error("in getMethodDefinitionFromMethodInfo, could not map MethodInfo: {0}", methodInfo.ToString());
     return null;
 }
开发者ID:CallMeSteve,项目名称:O2.Platform.Scripts,代码行数:15,代码来源:CecilConvert.cs

示例12: IsValidForRequest

        // Methods
        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
        {
            #region Contracts

            if (controllerContext == null) throw new ArgumentNullException();
            if (methodInfo == null) throw new ArgumentNullException();

            #endregion

            // ParameterInfoArray
            var parameterInfoArray = ParameterInfoFactory.Current.GetAll(controllerContext.Controller.GetType(), methodInfo);
            if (parameterInfoArray == null) throw new InvalidOperationException();

            // Current Overload Action Matching
            if (this.IsOverloadMatched(controllerContext, parameterInfoArray) == false)
            {
                return false;
            }

            // Other MethodInfoArray
            var otherMethodInfoArray = MethodInfoFactory.Current.GetAll(controllerContext.Controller.GetType());
            if (otherMethodInfoArray == null) throw new InvalidOperationException();
            
            // Other Overload Action Matching
            foreach (var otherMethodInfo in otherMethodInfoArray)
            {
                // MethodInfo
                if (otherMethodInfo.Name != methodInfo.Name) continue;
                if (otherMethodInfo.ToString() == methodInfo.ToString()) continue;
                if (otherMethodInfo.GetCustomAttribute<OverloadAttribute>() == null) continue;

                // ParameterInfoArray
                var otherParameterInfoArray = ParameterInfoFactory.Current.GetAll(controllerContext.Controller.GetType(), otherMethodInfo);
                if (otherParameterInfoArray == null) throw new InvalidOperationException();
                if (otherParameterInfoArray.Length < parameterInfoArray.Length) continue;

                // IsOverloadMatched
                if (this.IsOverloadMatched(controllerContext, otherParameterInfoArray) == true) return false;
            }

            // Return
            return true;
        }
开发者ID:Clark159,项目名称:CLK.Web.Mvc,代码行数:44,代码来源:OverloadAttribute.cs

示例13: GetMethodDelegate

        public override DynamicMethodProxyHandler GetMethodDelegate(
            Module targetModule, 
            MethodInfo genericMethodInfo, 
            params Type[] genericParameterTypes)
        {
            #region  Construct cache key

            if (targetModule == null)
            {
                throw new ArgumentNullException("targetModule");
            }

            string key = targetModule.FullyQualifiedName + "|" + genericMethodInfo.DeclaringType.ToString() + "|" + genericMethodInfo.ToString();
            if (genericParameterTypes != null)
            {
                for (int i = 0; i < genericParameterTypes.Length; ++i)
                {
                    key += "|" + genericParameterTypes[i].ToString();
                }
            }

            #endregion

            DynamicMethodProxyHandler dmd;

            lock (cache2)
            {
                if (cache2.ContainsKey(key))
                {
                    dmd = cache2[key];
                }
                else
                {
                    dmd = DoGetMethodDelegate(targetModule, genericMethodInfo, genericParameterTypes);
                    cache2.Add(key, dmd);
                }
            }

            return dmd;
        }
开发者ID:Oman,项目名称:Maleos,代码行数:40,代码来源:DynamicMethodProxyFactory.cs

示例14: GetMethodInvoker

        public static MethodInvokerBase GetMethodInvoker(object targetObject, MethodInfo mi)
        {
            var typeName = "EmitMapper.MethodCaller_" + mi.ToString();

            Type callerType = _typesCache.Get<Type>(
                typeName,
                () =>
                {
                    if (mi.ReturnType == typeof(void))
                    {
                        return BuildActionCallerType(typeName, mi);
                    }
                    else
                    {
                        return BuildFuncCallerType(typeName, mi);
                    }
                }
            );

            MethodInvokerBase result = (MethodInvokerBase)Activator.CreateInstance(callerType);
            result.targetObject = targetObject;
            return result;
        }
开发者ID:antonovicha,项目名称:EmitMapperRedux,代码行数:23,代码来源:MethodInvoker.cs

示例15: GenerateRule

        public static ProductionRule GenerateRule(MethodInfo method)
        {
            ProductionAttribute production =
                (ProductionAttribute)Attribute.GetCustomAttribute(method, typeof(ProductionAttribute), false);

            if (production == null)
            {
                return null;
            }

            Type[] newLeft, left, strict, right, newRight;
            production.GetTypes(method, out newLeft, out left, out strict, out right, out newRight);

            var ignoreList = IgnoreAttribute.GetIgnoredTypes(method);
            foreach(var p in method.GetParameters())
            {
                if (ignoreList.Contains(p.ParameterType))
                {
                    throw new InvalidOperationException(string.Format(
                        "ProductionRule: Ignored type is production function parameters list (class: {0}, method: {1}).", method.DeclaringType.Name, method.ToString()));
                }
            }

            Array.Reverse(newLeft);
            Array.Reverse(left);

            return new ProductionRule()
            {
                Method = method,
                NewLeft = newLeft,
                Left = left,
                Strict = strict,
                Right = right,
                NewRight = newRight,
                IgnoreList = ignoreList
            };
        }
开发者ID:Jaimerh,项目名称:lsystems-csharp-lib,代码行数:37,代码来源:ProductionRule.cs


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