本文整理汇总了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)
{
//.........这里部分代码省略.........