Option.dll
public class Option { public event EventHandler<OptionEventArgs> OnBought; public void Buy() { Console.WriteLine("Buying option..."); if (OnBought != null) OnBought(this, new OptionEventArgs("Successfully bought!", 120.50)); } } public class OptionEventArgs : EventArgs { public string Message { get; set; } public double Lots { get; set; } public OptionEventArgs() { } public OptionEventArgs(string message, double lots) { Message = message; Lots = lots; } }
OnBought
static void Main(string[] args) { Assembly asm = null; try { asm = Assembly.Load("Option"); Type option = asm.GetType("Option.Option"); dynamic opt = Activator.CreateInstance(option); //now i want to register OnBought event... } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)