コード例 #1
0
ファイル: Engine.cs プロジェクト: arBmind/Twofold.Net
        /// <summary>
        /// Executed a compiled Twofold template.
        /// </summary>
        /// <typeparam name="T">The argument type of the template main method.</typeparam>
        /// <param name="compiledTemplate">The compiled Twofold template.</param>
        /// <param name="arguments">The arguments which is given to the template main method.</param>
        /// <returns>The generated target text or null if an error occured.</returns>
        /// <exception cref="ArgumentNullException">If compiledTemplate is null.</exception>
        public Target Run(CompiledTemplate compiledTemplate, params object[] arguments)
        {
            var    templateExecuter = new TemplateExecuter(this.MessageHandler);
            Target target           = templateExecuter.Execute(compiledTemplate, arguments);

            return(target);
        }
コード例 #2
0
        public string RunLua(TemplateConfig config)
        {
            var executer = new TemplateExecuter();
            var lua      = executer.InitLua(Context.SelectConfig);

            lua.DoString(CurrentTemplateConfig.Code);
            lua.DoString($"{config.Name}()");
            var code = executer.ResultCode;

            return(code != null?code.FromLuaChar() : string.Empty);
        }