Place this in a text file
Code:1%this%that%what 1:What do you want to achieve this or that?:this:Say you have achieved this:that:say you have achieved that:what:What is itCode:using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.IO; namespace AssemblyTest { public class Program { static Dictionary<string, string> dict = new Dictionary<string, string>(); static string[] choices; static void Main(string[] args) { Load(); Console.WriteLine(dict["1"]); wait(); } public static void wait() { while (true) { string choice = Console.ReadLine(); if(choices.Contains(choice)) { invokeWrite("DynamicFunction", "writeLine", new object[1] { dict[choice] }); } } } public static void invokeWrite(string tarClass, string tarMethod, object[] objs) { foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { if (t.FullName.EndsWith(tarClass)) { Object asb = Activator.CreateInstance(t); MethodInfo mi = asb.GetType().GetMethod(tarMethod); mi.Invoke(asb, objs); } } } static void Load() { TextReader tr = new StreamReader(@"C:\Documents and Settings\%user%\My Documents\test.txt"); choices = tr.ReadLine().Split('%'); string[] process2 = tr.ReadToEnd().Split(':'); for (int i = 0; i < process2.Length; i += 2) { dict.Add(process2[i], process2[i + 1]); } } } public class DynamicFunction { public static void writeLine(string args) { Console.WriteLine(args); } } }
Edit this line
TextReader tr = new StreamReader(@"C:\Documents and Settings\%user%\My Documents\test.txt");
change it to your text location...
Assembly is used for runtime execution of functions that have been compiled. =) The above shows a very simple script.



Reply With Quote![[C#] Assembly =)](http://ragezone.com/hyper728.png)

