public void DetectType() { var reflector = new TypeReflection(); var t1 = reflector.GetType(); var t2 = typeof(TypeReflection); var t3 = Type.GetType("ExtendedSharp.TypeReflection"); if (t1.ToString() == t2.ToString() && t2.ToString() == t3.ToString()) { Console.WriteLine("Types Equal"); } }
public void InvokeMethodNoArgs() { var t1 = typeof(TypeReflection); //find needed method var methodInfo = t1.GetMethods().FirstOrDefault(t => t.Name.StartsWith("TestMethod")); //create instance var reflector = Activator.CreateInstance(t1); methodInfo.Invoke(reflector, null); var r2 = new TypeReflection(); methodInfo.Invoke(r2, null); }