public CurveScript(string Filename, bool v) { FileName = Filename; Assembly dll = Assembly.LoadFile(FileName); try { _baseType = dll.GetType("Plugins.CurvePlugin"); Init = (Action)Delegate.CreateDelegate(typeof(Action), _baseType.GetMethod("Init")); GetInfo = (Func <CurveInfo>)Delegate.CreateDelegate(typeof(Func <CurveInfo>), _baseType.GetMethod("GetInfo")); PreviewImage = (Func <Size, double, object, double, Image>)Delegate.CreateDelegate(typeof(Func <Size, double, object, double, Image>), _baseType.GetMethod("PreviewImage")); PreviewImageGif = (Func <GifImage>)Delegate.CreateDelegate(typeof(Func <GifImage>), _baseType.GetMethod("PreviewImageGif")); GetVector = (Func <ToVectorParams, Vector>)Delegate.CreateDelegate(typeof(Func <ToVectorParams, Vector>), _baseType.GetMethod("GetVector")); Exmpl1 = (Func <CurveExample>)Delegate.CreateDelegate(typeof(Func <CurveExample>), _baseType.GetMethod("Exmpl1")); Exmpl2 = (Func <CurveExample>)Delegate.CreateDelegate(typeof(Func <CurveExample>), _baseType.GetMethod("Exmpl2")); //Console.WriteLine("Done."); } catch (Exception e) { MessageBox.Show(e.Message + "\n============\n" + e.StackTrace); Environment.Exit(0); } Init(); Info = GetInfo(); Name = Info.Name; }
public CurveScript(string Filename) { FileName = Filename; ExecuteScript(File.ReadAllText(Filename, Encoding.ASCII)); Init(); Info = GetInfo(); Name = Info.Name; }