当前位置: 首页>>代码示例>>C#>>正文


C# IScriptEngine.Run方法代码示例

本文整理汇总了C#中IScriptEngine.Run方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptEngine.Run方法的具体用法?C# IScriptEngine.Run怎么用?C# IScriptEngine.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScriptEngine的用法示例。


在下文中一共展示了IScriptEngine.Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Preprocess

        /// <summary>
        /// This function preprosses the mako layer
        /// </summary>
        /// <param name="input">The input string to parse</param>
        /// <param name="argument">The argument sent to the parser</param>
        public String Preprocess(string input, string argument, bool inflate, string uri, bool onlyPreprocess = false)
        {
            #region OverlayManager Experimental
            /****
             * STOCKHOLM 2011-07-01 14:45
             *
             * New feature: Apply custom overlays specified by individual service:
             * Overlay are marked with <#namespace#> where "namespace" is an special
             * kind of <namespace>.xml view file inside an <extension_dir>/views/ folder
             * */

            // First gain attention by the event

            OverlayEventArgs args = new OverlayEventArgs(); // Create event args
            args.URI = uri;
            if (RequestOverlay != null)
                RequestOverlay(this, args);

            // if the args has retained the phase, eg. not cancelled
            if (!args.Cancel)
            {
                // Substitute the overlay placeholders with the views
                if(args.ViewFolders != null)
                foreach (KeyValuePair<string, string> overlay in args.ViewFolders)
                {
                    using (StreamReader SR = new StreamReader(overlay.Value))
                    {
                        String content = SR.ReadToEnd();
                        // Substitute overlay placeholders
                        input = input.Replace("<#" + overlay.Key.Replace(".xml","") + "#>", content);
                        SR.Close();
                    }
                }
            }

            // Remove unwanted trailings
            Regex a = new Regex(@"<\#[^\#]*\#>", RegexOptions.IgnoreCase);
            input = a.Replace(input, "");
            #endregion

            /**
             * Begin normal operation
             * */

            // Clear the output buffer
            Output = "";
            /**
             * Tell the runtime machine about the argument
             * */
            try
            {
                String[] arguments = argument.Split(':');
                RuntimeMachine.SetVariable("parameter", argument.Replace(arguments[0] + ":", "").Replace(arguments[1] + ":", ""));
                RuntimeMachine.SetVariable("service", arguments[0]);
            }
            catch { }
            /**
             * This string defines the call-stack of the query
             * This is done before any other preprocessing
             * */
            String CallStack = "";
            String[] lines = input.Split('\n');
            /**
             * Boolean indicating which parse mode the parser is in,
             * true = in executable text
             * false = in output line
             * */
            bool parseMode = false;
            // Boolean indicating first line is parsing
            bool firstLine = true;
            /***
             * Iterate through all lines and preprocess the page.
             * If page starts with an % it will be treated as an preparser code or all content
             * inside enclosing <? ?>
             * Two string builders, the first is for the current output segment and the second for the current
             * executable segmetn
             * */
            StringBuilder outputCode =  new StringBuilder();
            StringBuilder executableSegment = new StringBuilder();

            // The buffer for the final preprocessing output
            StringBuilder finalOutput = new StringBuilder();
            // Append initial case
            outputCode.Append("");

            // Boolean startCase. true = <? false \n%
            bool startCase = false;

            // Boolean which tells if the cursor is in the preparse or output part of the buffer (inside or outside an executable segment)
            bool codeMode = false;
            for(int i=0; i < input.Length ;i++)
            {
                 // Check if at an overgoing to an code block
                if(codeMode)
                {
//.........这里部分代码省略.........
开发者ID:krikelin,项目名称:LerosClient,代码行数:101,代码来源:Mako.cs


注:本文中的IScriptEngine.Run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。