/// <summary> /// Compiles the and create object. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="instructions">The instructions.</param> /// <param name="constructorParameters">The constructor parameters.</param> /// <returns></returns> public static object CompileAndCreateObject(this ICompiler compiler, ICompilerInstructions instructions, params object[] constructorParameters) { var assembly = compiler.Compile(instructions.Code, instructions.AssemblyLocations); var type = assembly.GetType(instructions.ClassName); return(Activator.CreateInstance(type, constructorParameters)); }
/// <summary> /// Runs the script. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="instructions">The instructions.</param> /// <param name="constructorParameters">The constructor parameters. Leave empty when the constructor has no parameters.</param> public static void RunScript(this ICompiler compiler, ICompilerInstructions instructions, params object[] constructorParameters) { var scriptObject = CompileAndCreateObject <IScript>(compiler, instructions, constructorParameters); scriptObject.Run(); }
/// <summary> /// Runs the producer. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="instructions">The instructions.</param> /// <param name="constructorParameters">The constructor parameters. Leave empty when the constructor has no parameters.</param> /// <returns></returns> public static object RunProducer(this ICompiler compiler, ICompilerInstructions instructions, params object[] constructorParameters) { var scriptObject = CompileAndCreateObject <IProducer>(compiler, instructions, constructorParameters); return(scriptObject.Run()); }
/// <summary> /// Compiles the and create object. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="compiler">The compiler.</param> /// <param name="instructions">The instructions.</param> /// <param name="constructorParameters">The constructor parameters.</param> /// <returns></returns> public static T CompileAndCreateObject <T>(this ICompiler compiler, ICompilerInstructions instructions, params object[] constructorParameters) { return((T)compiler.CompileAndCreateObject(instructions, constructorParameters)); }
public static object CompileAndCreateObject(this ICompiler compiler, ICompilerInstructions instructions, params object[] constructorParameters) { return(Activator.CreateInstance(instructions.ClassType, constructorParameters)); }