本文整理汇总了C#中System.Management.Automation.ScriptBlock.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptBlock.Compile方法的具体用法?C# ScriptBlock.Compile怎么用?C# ScriptBlock.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Automation.ScriptBlock
的用法示例。
在下文中一共展示了ScriptBlock.Compile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PSScriptCmdlet
public PSScriptCmdlet(ScriptBlock scriptBlock, bool useNewScope, bool fromScriptFile, ExecutionContext context)
{
_scriptBlock = scriptBlock;
_useLocalScope = useNewScope;
_fromScriptFile = fromScriptFile;
_runOptimized = _scriptBlock.Compile(optimized: context._debuggingMode > 0 ? false : useNewScope);
_localsTuple = _scriptBlock.MakeLocalsTuple(_runOptimized);
_localsTuple.SetAutomaticVariable(AutomaticVariable.PSCmdlet, this, context);
_scriptBlock.SetPSScriptRootAndPSCommandPath(_localsTuple, context);
_functionContext = new FunctionContext
{
_localsTuple = _localsTuple,
_scriptBlock = _scriptBlock,
_file = _scriptBlock.File,
_sequencePoints = _scriptBlock.SequencePoints,
_debuggerHidden = _scriptBlock.DebuggerHidden,
_debuggerStepThrough = _scriptBlock.DebuggerStepThrough,
_executionContext = context,
};
_rethrowExitException = context.ScriptCommandProcessorShouldRethrowExit;
context.ScriptCommandProcessorShouldRethrowExit = false;
}
示例2: Init
private void Init()
{
_scriptBlock = base._scriptBlock;
_obsoleteAttribute = _scriptBlock.ObsoleteAttribute;
_runOptimizedCode = _scriptBlock.Compile(optimized: _context._debuggingMode > 0 ? false : UseLocalScope);
_localsTuple = _scriptBlock.MakeLocalsTuple(_runOptimizedCode);
}