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


C# System.GetMethod方法代码示例

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


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

示例1: StackFrame

        public StackFrame(System.Diagnostics.StackFrame frame)
            : this()
        {
            Method = frame.GetMethod().ToString();
            MethodType = frame.GetMethod().DeclaringType.ToString();

            FileName = frame.GetFileName();
            FileLine = frame.GetFileLineNumber();
            FileColumn = frame.GetFileColumnNumber();
        }
开发者ID:rmbzlib,项目名称:mcskin3d,代码行数:10,代码来源:ErrorReport.cs

示例2: Convert

 public static void Convert(
     System.Type conversionClass,
     Bam.Core.Settings settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     var moduleType = typeof(Bam.Core.Module);
     var vsSettingsGroupType = typeof(VSSolutionBuilder.VSSettingsGroup);
     var stringType = typeof(string);
     foreach (var i in settings.Interfaces())
     {
         var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, vsSettingsGroupType, stringType });
         if (null == method)
         {
             throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})",
                 conversionClass.ToString(),
                 i.ToString(),
                 moduleType,
                 vsSettingsGroupType,
                 stringType);
         }
         try
         {
             method.Invoke(null, new object[] { settings, module, vsSettingsGroup, condition });
         }
         catch (System.Reflection.TargetInvocationException exception)
         {
             throw new Bam.Core.Exception(exception.InnerException, "VisualStudio conversion error:");
         }
     }
 }
开发者ID:knocte,项目名称:BuildAMation,代码行数:32,代码来源:Conversion.cs

示例3: Convert

 Convert(
     System.Type conversionClass,
     Bam.Core.Settings toolSettings,
     Bam.Core.StringArray commandLine)
 {
     var stringArrayType = typeof(Bam.Core.StringArray);
     foreach (var i in toolSettings.Interfaces())
     {
         var method = conversionClass.GetMethod("Convert", new[] { i, stringArrayType });
         if (null == method)
         {
             throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2})",
                 conversionClass.ToString(),
                 i.ToString(),
                 stringArrayType);
         }
         var commands = new Bam.Core.StringArray();
         try
         {
             method.Invoke(null, new object[] { toolSettings, commands });
         }
         catch (System.Reflection.TargetInvocationException exception)
         {
             throw new Bam.Core.Exception(exception.InnerException, "Command line conversion error:");
         }
         commandLine.AddRange(commands);
     }
 }
开发者ID:knocte,项目名称:BuildAMation,代码行数:28,代码来源:Conversion.cs

示例4: Create

        /// <summary>
        /// Creates a SARIF StackFrame instance from a .NET StackFrame instance
        /// </summary>
        /// <param name="stackTrace"></param>
        /// <returns></returns>
        public static StackFrame Create(System.Diagnostics.StackFrame dotNetStackFrame)
        {
            // This value is -1 if not present
            int ilOffset = dotNetStackFrame.GetILOffset();
            string fileName = dotNetStackFrame.GetFileName();
            int nativeOffset = dotNetStackFrame.GetNativeOffset();
            MethodBase methodBase = dotNetStackFrame.GetMethod();
            Assembly assembly = methodBase?.DeclaringType.Assembly;
            string fullyQualifiedName = CreateFullyQualifiedName(methodBase);

            StackFrame stackFrame = new StackFrame
            {
                Module = assembly?.GetName().Name,
                FullyQualifiedLogicalName = fullyQualifiedName
            };

            if (fileName != null)
            {
                stackFrame.Uri = new Uri(fileName);
                stackFrame.Line = dotNetStackFrame.GetFileLineNumber();
                stackFrame.Column = dotNetStackFrame.GetFileColumnNumber();
            }

            if (ilOffset != -1)
            {
                stackFrame.Offset = ilOffset;
            }

            if (nativeOffset != -1)
            {
                stackFrame.SetProperty("NativeOffset", nativeOffset.ToString(CultureInfo.InvariantCulture));
            }

            return stackFrame;
        }
开发者ID:Microsoft,项目名称:sarif-sdk,代码行数:40,代码来源:StackFrame.cs

示例5: Convert

 public static void Convert(
     System.Type conversionClass,
     Bam.Core.Settings toolSettings,
     Bam.Core.Module module,
     XcodeBuilder.Configuration configuration)
 {
     var moduleType = typeof(Bam.Core.Module);
     var xcodeConfigurationType = typeof(XcodeBuilder.Configuration);
     foreach (var i in toolSettings.Interfaces())
     {
         var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, xcodeConfigurationType });
         if (null == method)
         {
             throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})",
                 conversionClass.ToString(),
                 i.ToString(),
                 moduleType,
                 xcodeConfigurationType);
         }
         try
         {
             method.Invoke(null, new object[] { toolSettings, module, configuration });
         }
         catch (System.Reflection.TargetInvocationException exception)
         {
             throw new Bam.Core.Exception(exception.InnerException, "Xcode conversion error:");
         }
     }
 }
开发者ID:knocte,项目名称:BuildAMation,代码行数:29,代码来源:Conversion.cs

示例6: AddMethodToLookup

 static void AddMethodToLookup(System.Type type, SceneViewTool obj, string methodName, EventType eventType)
 {
     if (!methods.ContainsKey (eventType))
         methods.Add (eventType, new List<MethodRef> ());
     var method = type.GetMethod (methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
     if (method != null)
         methods[eventType].Add (new MethodRef (obj, method));
 }
开发者ID:mstevenson,项目名称:SceneViewTools,代码行数:8,代码来源:SceneViewToolController.cs

示例7: executeMethod

 ///<summary>
 ///Executes a static method using reflection
 ///</summary>
 public static object executeMethod(System.Type t, string toExecute, object[] commands)
 {
     System.Reflection.MethodInfo methodInfo = t.GetMethod(toExecute);
       if (methodInfo == null)
       {
       return null;
       }
       return methodInfo.Invoke(null, commands);
 }
开发者ID:Powerino,项目名称:activizdotnet,代码行数:12,代码来源:CSharpTestDriver.cs

示例8: RunMethod

		private static object RunMethod(System.Type t, string strMethod, object objInstance, BindingFlags eFlags, object[] aobjParams)
		{
			MethodInfo m = t.GetMethod(strMethod, eFlags);
			if (m == null)
			{
				throw new ArgumentException("There is no method '" + strMethod + "' for type '" + t.ToString() + "'.");
			}
			return m.Invoke(objInstance, aobjParams);
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:9,代码来源:Helper.cs

示例9: AddToHotNodeButton

 void AddToHotNodeButton(System.Type t)
 {
     var tip = "";
     var method = t.GetMethod("GetHelpText");
     tip = (string)method.Invoke(null,null);
     var label = new GUIContent(t.Name, tip);
     if (GUILayout.Button (label, GUILayout.Width (100)))
         AddToHotNode (t);
 }
开发者ID:s76,项目名称:testAI,代码行数:9,代码来源:ReactEditor.cs

示例10: RunMethod

        public static object RunMethod(System.Type t,
			string methodName, object objInstance, object[] objParams, BindingFlags eFlags)
        {
            MethodInfo m = t.GetMethod(methodName, eFlags);
            if (m == null)
            {
                throw new ArgumentException("There is no method '" +
                 methodName + "' for type '" + t.ToString() + "'.");
            }

            object objRet = m.Invoke(objInstance, objParams);
            return objRet;
        }
开发者ID:Yuanxiangz,项目名称:WorkSpace,代码行数:13,代码来源:Utils.cs

示例11: Create

        /// <summary>
        /// Creates a <see cref="StackTrace"/> from the .NET system <see cref="System.Diagnostics.StackFrame"/>
        /// </summary>
        /// <param name="stackFrame"></param>
        /// <returns></returns>
        public static StackFrame Create(System.Diagnostics.StackFrame stackFrame) {
            MethodBase method = stackFrame.GetMethod();
            Type declaringType = method.DeclaringType; // can be null for auto-generated expression trees
            string fullName = declaringType != null ? declaringType.FullName : null;

            return new StackFrame {
                                      ColumnNumber = stackFrame.GetFileColumnNumber(),
                                      FilePath = TryGetFileName(stackFrame),
                                      LineNumber = stackFrame.GetFileLineNumber(),
                                      ILOffset = stackFrame.GetILOffset(),
                                      MethodName = method.ToString(),
                                      TypeName = fullName
                                  };
        }
开发者ID:julianpaulozzi,项目名称:EntityProfiler,代码行数:19,代码来源:StackFrame.cs

示例12: CallMethod

        public static object CallMethod(object target, System.Type type, string methodCMD)
        {
            string method_str = "";
            string parasCMD = "";
            object[] paras = null;

            method_str = methodCMD.Substring(0,methodCMD.IndexOf("("));
            parasCMD =  methodCMD.Substring(methodCMD.IndexOf("("), methodCMD.Length - methodCMD.IndexOf("("));
            parasCMD = parasCMD.Substring( 1, parasCMD.Length - 2);
            if(!parasCMD .Equals( "" )){
                if(parasCMD.Contains(",")){
                    string[] strParas = parasCMD.Split(',');
                    paras = new object[strParas.Length];
                    for (int pos = 0; pos < strParas.Length; pos++) {
                        //  TODO loop in strParas
            //					paras[pos] = int.Parse( strParas[pos] );
            //					if(strParas[pos].Contains("\"")){
            //						paras.SetValue(parasCMD.Replace("\"",""),pos);
            //					}
            //
            //					else
            //						paras.SetValue(int.Parse(strParas[pos]),pos);
                        paras.SetValue(GetParaFromString(strParas[pos]),pos);
                    }
                }else{
                    paras = new object[1];
                    paras.SetValue(GetParaFromString(parasCMD),0);

            //				if(parasCMD.Contains("\"")){
            //					parasCMD = parasCMD.Replace("\"","");
            //					paras.SetValue(parasCMD,0);
            ////					paras.SetValue(parasCMD,0);
            //				}
            //				else
            //					paras.SetValue(int.Parse(parasCMD),0);
            //				paras[0] = int.Parse( parasCMD );
                }
            }
            MethodInfo[] thods = type.GetMethods();

            //		MethodInfo method = type.GetMethod(method_str,System.Reflection.BindingFlags.);
            MethodInfo method = type.GetMethod(method_str);
            if( null == method){
                XLogger.Log(target + " not have a " + method_str + " method." );
                return null;
            }
            object returnValue = method.Invoke(target,paras);
            return returnValue;
        }
开发者ID:wuxingogo,项目名称:WuxingogoExtension,代码行数:49,代码来源:XReflectionManager.cs

示例13: GetGUITargetAttrValue

 private static int GetGUITargetAttrValue(System.Type klass, string methodName)
 {
   MethodInfo method = klass.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
   if (method != null)
   {
     object[] customAttributes = method.GetCustomAttributes(true);
     if (customAttributes != null)
     {
       for (int index = 0; index < customAttributes.Length; ++index)
       {
         if (customAttributes[index].GetType() == typeof (GUITargetAttribute))
           return (customAttributes[index] as GUITargetAttribute).displayMask;
       }
     }
   }
   return -1;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:17,代码来源:GUITargetAttribute.cs

示例14: GetMethod

        private static MethodInfo GetMethod(System.Type methodType, string methodName)
        {
            System.Type[] type = null;
            switch (methodName)
            {
                case "Contains":
                case "StartsWith":
                    type = new System.Type[] { methodType };
                    break;
                case "ToLower":
                case "ToString":
                default:
                    type = System.Type.EmptyTypes;
                    break;
            }

            return methodType.GetMethod(methodName, type);
        }
开发者ID:BoccaDamian,项目名称:bubis,代码行数:18,代码来源:LinqHelper.cs

示例15: GetMethodFromInterface

        private static MethodInfo GetMethodFromInterface(System.Type type, string methodName, System.Type[] parameterTypes)
        {
            const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly;
            if (type == null)
                return null;

            MethodInfo method = type.GetMethod(methodName, flags, null, parameterTypes, null);
            if (method == null)
            {
                System.Type[] interfaces = type.GetInterfaces();
                foreach (var @interface in interfaces)
                {
                    method = GetMethodFromInterface(@interface, methodName, parameterTypes);
                    if (method != null)
                        return method;
                }
            }
            return method;
        }
开发者ID:andoco,项目名称:mongodb-csharp,代码行数:19,代码来源:ReflectionExtensions.cs


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