本文整理汇总了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();
}
示例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:");
}
}
}
示例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);
}
}
示例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;
}
示例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:");
}
}
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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
};
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}