Пример #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));
 }