private void _AddMethod_Exec(object parameter) { var emptyMethod = new FormElement(this) { Elements = MainView.LoadedDiagram.SubjectMethods, Types = MainView.LoadedDiagram.Subjects, SubElements = new ObservableCollection <FormElement>() }; MethodElements.Add(emptyMethod); }
private MethodInfo GetRunMethod() { if (_runMethodName == null) { throw new PBException("run method name is null"); } MethodElements runMethodElements = zReflection.GetMethodElements(_runMethodName); if (runMethodElements.TypeName == null) { throw new PBException("bad run method name \"{0}\", run method need type name", _runMethodName); } Type runType; if (runMethodElements.QualifiedTypeName != null) { runType = zReflection.GetType(runMethodElements.QualifiedTypeName, ErrorOptions.ThrowError); } else { runType = zReflection.GetType(_runAssembly, runMethodElements.TypeName, ErrorOptions.ThrowError); } return(zReflection.GetMethod(runType, runMethodElements.MethodName, ErrorOptions.ThrowError)); }
//string typeName public static string Test_GetMethod_01(string methodName, bool test = true) { // "pb.Reflection.Test.Test_MethodInfo.Test_01" MethodElements methodElements = zReflection.GetMethodElements(methodName); methodElements.zTraceJson(); //Trace.WriteLine("Test_MethodInfo.Test_01"); //Assembly.GetExecutingAssembly() //Assembly.GetCallingAssembly() //Assembly.GetEntryAssembly() Assembly assembly; if (methodElements.AssemblyName != null) { assembly = zReflection.GetAssembly(methodElements.AssemblyName, ErrorOptions.None); } else { assembly = Assembly.GetExecutingAssembly(); } if (assembly != null) { Trace.WriteLine($"assembly {assembly.FullName}"); } else { Trace.WriteLine("assembly not found"); return(null); } Type type = zReflection.GetType(assembly, methodElements.TypeName, ErrorOptions.TraceWarning); if (type != null) { Trace.WriteLine($"type {type.AssemblyQualifiedName}"); } else { Trace.WriteLine("type not found"); return(null); } MethodInfo methodInfo = zReflection.GetMethod(type, methodElements.MethodName, ErrorOptions.TraceWarning); if (methodInfo != null) { Trace.WriteLine($"method {methodInfo.zGetName()}"); } else { Trace.WriteLine("method not found"); return(null); } Trace.WriteLine($"method definition {zReflection.GetDefinition(methodInfo)}"); ParameterInfo[] parameters = methodInfo.GetParameters(); Trace.WriteLine($"method parameters : count {parameters.Length}"); foreach (ParameterInfo parameter in parameters) { TraceParameterInfo(parameter); Trace.WriteLine(); } Trace.WriteLine($"method return parameter :"); TraceParameterInfo(methodInfo.ReturnParameter); return(null); }