Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Reflekcja assembly, instancja i metoda
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { string assemblyName="userAssembly"; string typeName="Rextester.Program"; string methodName="testrun"; //foreach(var a in AppDomain.CurrentDomain.GetAssemblies()) Console.WriteLine(a.FullName); var assembly = AppDomain.CurrentDomain.GetAssemblies().Where(x=>x.FullName.StartsWith(assemblyName)).FirstOrDefault(); if(assembly==null) return; Console.Write("assembly: "); Console.WriteLine(assembly.FullName); //foreach(var t in assembly.GetTypes()) Console.WriteLine(t.FullName.Split('+')[0]); var type = assembly.GetTypes().Where(x=>x.FullName.StartsWith(typeName)).FirstOrDefault(); if(type==null) return; Console.Write("type: "); Console.WriteLine(type); object instance = Activator.CreateInstance(type); if(instance==null) return; Console.Write("instance: "); Console.WriteLine(instance); //foreach(var m in type.GetMethods()) Console.WriteLine(m.Name); var method = type.GetMethod(methodName); if(method==null) return; Console.Write("method: "); Console.WriteLine(method); object ret = method.Invoke(instance, new object[] {"udało się!"}); Console.Write("rezultat: "); Console.WriteLine(ret); } public object testrun(string arg) { Console.WriteLine("START"); Console.WriteLine(arg); Console.WriteLine("KONIEC"); return 99m; } } }
run
|
edit
|
history
|
help
0
Sort string collection by length
Joro Football Player
free robux
Pyramid using C#
Melody
GYT
Collection_ basic datastructure brushup
utf-8 string to bytes and back
GetDataFromSQLGroups
Code