모든 리플렉션을 사용하여 모든 메서드에서 모든 메서드를 가져 오려고합니다. 나는 내 코드를 여기에있다. 클래스 이름을 얻을 수 있지만 메소드 이름을 가져올 수 없습니다. 내가 어떻게 할 수 있니?모든 메서드 이름 검색
string @namespace = "Application.Main";
List<String> methodNames = new List<string>();
List<String> appServiceClasses = new List<string>();
List<Type> returnVal = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(t => t.GetTypes())
.Where(t => t.IsClass && t.Namespace == @namespace).ToList();
for (int i = 0; i < returnVal.Count; i++)
{
appServiceClasses.Add(returnVal[i].Name);
}
Type myTypeObj = typeof(appServiceClasses[0]);
MethodInfo[] methodInfos = myTypeObj.GetMethods();
foreach (MethodInfo methodInfo in methodInfos)
{
string a = methodInfo.Name;
}
'대해서 typeof (appServiceClasses [0])'이 컴파일은? –
아니요. 나는 길을 많이 시도한다. 그것은 typeof (CLASS)가되어야하지만 클래스 이름이 문자열이다. 어떻게 할 수 있는가? – Curious