本文整理汇总了C#中ScriptState类的典型用法代码示例。如果您正苦于以下问题:C# ScriptState类的具体用法?C# ScriptState怎么用?C# ScriptState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScriptState类属于命名空间,在下文中一共展示了ScriptState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithScriptState
internal EvaluationState WithScriptState(ScriptState<object> state)
{
return new EvaluationState(
state,
ScriptOptions,
SourceSearchPaths,
ReferenceSearchPaths,
WorkingDirectory);
}
示例2: ScriptResult
public ScriptResult(
ScriptState state,
string output,
TimeSpan elapsed = default(TimeSpan))
{
this.State = state;
this.Output = output;
this.Elapsed = elapsed;
}
示例3: LogPack
public LogPack(
ulong tweetId,
DateTimeOffset tweetTime,
string scriptContent,
string resultContent,
ScriptState state)
{
this.TweetId = tweetId;
this.TweetTime = tweetTime;
this.ScriptContent = scriptContent;
this.ResultContent = resultContent;
this.State = state;
}
示例4: EvaluationState
internal EvaluationState(
ScriptState<object> scriptState,
ScriptOptions scriptOptions,
ImmutableArray<string> sourceSearchPaths,
ImmutableArray<string> referenceSearchPaths,
string workingDirectory)
{
ScriptStateOpt = scriptState;
ScriptOptions = scriptOptions;
SourceSearchPaths = sourceSearchPaths;
ReferenceSearchPaths = referenceSearchPaths;
WorkingDirectory = workingDirectory;
}
示例5: ExecuteScript
public void ExecuteScript(Script script)
{
// wrap the script in our state
ScriptState scriptState = new ScriptState(script);
// the script may complete in one go
scriptState.Execute(null);
// if not, add it to our list
if (!scriptState.IsComplete)
{
scripts.Add(scriptState);
}
}
示例6: EvaluationState
internal EvaluationState(
ScriptState<object> scriptStateOpt,
ScriptOptions scriptOptions,
ImmutableArray<string> sourceSearchPaths,
ImmutableArray<string> referenceSearchPaths,
string workingDirectory)
{
Debug.Assert(scriptOptions != null);
Debug.Assert(!sourceSearchPaths.IsDefault);
Debug.Assert(!referenceSearchPaths.IsDefault);
Debug.Assert(workingDirectory != null);
ScriptStateOpt = scriptStateOpt;
ScriptOptions = scriptOptions;
SourceSearchPaths = sourceSearchPaths;
ReferenceSearchPaths = referenceSearchPaths;
WorkingDirectory = workingDirectory;
}
示例7: SetScriptState
public override void SetScriptState(ScriptState state)
{
activeScript.SetScriptState(state);
}
示例8: ExecuteOnUIThread
private async Task<ScriptState<object>> ExecuteOnUIThread(Script<object> script, ScriptState<object> stateOpt)
{
return await Task.Factory.StartNew(async () =>
{
try
{
var task = (stateOpt == null) ?
script.RunAsync(_hostObject, CancellationToken.None) :
script.ContinueAsync(stateOpt, CancellationToken.None);
return await task.ConfigureAwait(false);
}
catch (Exception e)
{
// TODO (tomat): format exception
Console.Error.WriteLine(e);
return null;
}
},
CancellationToken.None,
TaskCreationOptions.None,
s_UIThreadScheduler).Unwrap().ConfigureAwait(false);
}
示例9: BuildAndRun
private void BuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object> state, ref ScriptOptions options, bool displayResult, CancellationToken cancellationToken)
{
var diagnostics = newScript.Compile(cancellationToken);
DisplayDiagnostics(diagnostics);
if (diagnostics.HasAnyErrors())
{
return;
}
var task = (state == null) ?
newScript.RunAsync(globals, catchException: e => true, cancellationToken: cancellationToken) :
newScript.RunFromAsync(state, catchException: e => true, cancellationToken: cancellationToken);
state = task.GetAwaiter().GetResult();
if (state.Exception != null)
{
DisplayException(state.Exception);
}
else if (displayResult && newScript.HasReturnValue())
{
globals.Print(state.ReturnValue);
}
options = UpdateOptions(options, globals);
}
示例10:
void IActiveScriptSite.OnStateChange(ScriptState scriptState)
{
//Trace.WriteLine("OnStateChange scriptState=" + scriptState);
}
示例11: Execute
/// <summary>
/// Executes the specified code.
/// </summary>
/// <param name="code">The code.</param>
private void Execute(string code)
{
try
{
InteractiveScriptBase.Current = scriptBase;
scriptBase._ScriptState_ = scriptState;
scriptState = scriptState.ContinueWithAsync(code).Result;
importedCode = ExtractImportedCode(scriptState.Script, importedCode);
UpdateUsings(scriptState.Script, usings);
UpdateReferences(scriptState.Script, references);
scriptBase.Dump(scriptState.ReturnValue);
if (scriptBase._InteractiveScriptBaseType_ != null && scriptBase._InteractiveScriptBaseType_ != scriptBase.GetType())
{
var oldScriptBase = scriptBase;
scriptBase = (InteractiveScriptBase)Activator.CreateInstance(scriptBase._InteractiveScriptBaseType_);
scriptBase.ObjectWriter = oldScriptBase.ObjectWriter;
scriptBase._InternalObjectWriter_ = oldScriptBase._InternalObjectWriter_;
// TODO: Changing globals, but we need to store previous variables
scriptState = CSharpScript.RunAsync("", scriptState.Script.Options, scriptBase).Result;
}
}
finally
{
InteractiveScriptBase.Current = null;
}
}
示例12: ExecuteOnUIThread
private async Task<ScriptState<object>> ExecuteOnUIThread(Script<object> script, ScriptState<object> stateOpt, bool displayResult)
{
return await ((Task<ScriptState<object>>)s_control.Invoke(
(Func<Task<ScriptState<object>>>)(async () =>
{
var task = (stateOpt == null) ?
script.RunAsync(_globals, catchException: e => true, cancellationToken: CancellationToken.None) :
script.RunFromAsync(stateOpt, catchException: e => true, cancellationToken: CancellationToken.None);
var newState = await task.ConfigureAwait(false);
if (newState.Exception != null)
{
DisplayException(newState.Exception);
}
else if (displayResult && newState.Script.HasReturnValue())
{
_globals.Print(newState.ReturnValue);
}
return newState;
}))).ConfigureAwait(false);
}
示例13: GetScriptState
public abstract void GetScriptState(out ScriptState state);
示例14: DisplaySubmissionResult
private static void DisplaySubmissionResult(ScriptState<object> state)
{
// TODO
//if (state.Script.GetCompilation().HasSubmissionResult())
if (state.ReturnValue != null)
{
state.ReturnValue.Dump();
}
}
示例15: TryBuildAndRun
private bool TryBuildAndRun(Script<object> newScript, object globals, ref ScriptState<object> state, CancellationToken cancellationToken)
{
var diagnostics = newScript.Build(cancellationToken);
DisplayDiagnostics(diagnostics);
if (diagnostics.HasAnyErrors())
{
return false;
}
try
{
var task = (state == null) ?
newScript.RunAsync(globals, cancellationToken) :
newScript.ContinueAsync(state, cancellationToken);
state = task.GetAwaiter().GetResult();
}
catch (Exception e)
{
DisplayException(e);
return false;
}
return true;
}