コード例 #1
0
        /// <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));
        }
コード例 #2
0
        /// <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();
        }
コード例 #3
0
        /// <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());
        }
コード例 #4
0
 /// <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));
 }
コード例 #5
0
 public static object CompileAndCreateObject(this ICompiler compiler, ICompilerInstructions instructions, params object[] constructorParameters)
 {
     return(Activator.CreateInstance(instructions.ClassType, constructorParameters));
 }