本文整理汇总了C#中Script.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Compile方法的具体用法?C# Script.Compile怎么用?C# Script.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Script
的用法示例。
在下文中一共展示了Script.Compile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScriptedMapping
public ScriptedMapping(string name, string scriptBody)
: base(name)
{
_script = CSharpScript.Create<string>(scriptBody, globalsType: typeof(ScriptGlobals));
var diagnostic = _script.Compile();
if (diagnostic.Any())
{
foreach (var message in diagnostic)
{
Console.WriteLine(message);
}
}
Globals = new ScriptGlobals();
}
示例2: CheckScriptValidity
private bool CheckScriptValidity(Script script)
{
var diagnostics = script.Compile();
if(!diagnostics.Any(d => d.WarningLevel == 0))
{
return true;
}
using (var sw = new StreamWriter(errorLogPath, true))
{
sw.WriteLine($"{DateTime.Now.ToLongDateString()}, {DateTime.Now.ToLongTimeString()}");
foreach (var d in diagnostics)
{
sw.WriteLine(d.ToString());
}
sw.WriteLine();
}
return false;
}
示例3: Compile
private void Compile(string filepath, string sourceCode)
{
var options = ScriptOptions.Default
.WithReferences(Assembly.GetExecutingAssembly())
.WithReferences(typeof(object).Assembly)
.WithReferences(Path.Combine(MayaRootPath, "bin", "openmayacs.dll"))
.WithFilePath(filepath);
_script = CSharpScript.Create(sourceCode, options);
var diags = _script.Compile();
if (diags.Length > 0)
{
foreach (var diag in diags)
{
MGlobal.displayError(diag.ToString());
}
throw new InvalidProgramException();
}
}
示例4: CreateScript
private void CreateScript()
{
var scriptText = ScriptText;
lock (typeof(ScriptingEngine))
{
Script<IQueryResult> existingScript;
if (_scripts.TryGetValue(scriptText, out existingScript))
{
_script = existingScript;
return;
}
}
_script = CSharpScript.Create<IQueryResult>(scriptText, globalsType: typeof (Globals), options: _options);
_script.Compile();
lock (typeof (ScriptingEngine))
{
_scripts[scriptText] = _script;
}
}