本文整理汇总了C#中RemoteAsyncOperation类的典型用法代码示例。如果您正苦于以下问题:C# RemoteAsyncOperation类的具体用法?C# RemoteAsyncOperation怎么用?C# RemoteAsyncOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteAsyncOperation类属于命名空间,在下文中一共展示了RemoteAsyncOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPathsAsync
public void SetPathsAsync(
RemoteAsyncOperation<RemoteExecutionResult> operation,
string[] referenceSearchPaths,
string[] sourceSearchPaths,
string baseDirectory)
{
Debug.Assert(operation != null);
Debug.Assert(referenceSearchPaths != null);
Debug.Assert(sourceSearchPaths != null);
Debug.Assert(baseDirectory != null);
lock (_lastTaskGuard)
{
_lastTask = SetPathsAsync(_lastTask, operation, referenceSearchPaths, sourceSearchPaths, baseDirectory);
}
}
示例2: AddReferenceAsync
private async Task<TaskResult> AddReferenceAsync(Task<TaskResult> lastTask, RemoteAsyncOperation<bool> operation, string reference)
{
var result = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
var success = false;
var options = result.Options;
try
{
string fullPath = ResolveReferencePath(options, reference, baseFilePath: null);
if (fullPath != null)
{
success = LoadReference(fullPath, suppressWarnings: false, addReference: true, options: ref options);
}
else
{
Console.Error.WriteLine(string.Format(FeaturesResources.CannotResolveReference, reference));
}
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
operation.Completed(success);
}
return result.With(options);
}
示例3: ExecuteFileAsync
private async Task<EvaluationState> ExecuteFileAsync(
RemoteAsyncOperation<RemoteExecutionResult> operation,
Task<EvaluationState> lastTask,
string path)
{
var state = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
var success = false;
try
{
var fullPath = ResolveRelativePath(path, state.WorkingDirectory, state.SourceSearchPaths, displayPath: false);
var newScriptState = await ExecuteFileAsync(state, fullPath).ConfigureAwait(false);
if (newScriptState != null)
{
success = true;
state = state.WithScriptState(newScriptState);
}
}
finally
{
state = CompleteExecution(state, operation, success);
}
return state;
}
示例4: ExecuteFileAsync
public void ExecuteFileAsync(RemoteAsyncOperation<RemoteExecutionResult> operation, string path)
{
Debug.Assert(operation != null);
Debug.Assert(path != null);
lock (_lastTaskGuard)
{
_lastTask = ExecuteFileAsync(operation, _lastTask, path);
}
}
示例5: InitializeContextAsync
/// <summary>
/// Loads references, set options and execute files specified in the initialization file.
/// Also prints logo unless <paramref name="isRestarting"/> is true.
/// </summary>
private async Task<EvaluationState> InitializeContextAsync(
Task<EvaluationState> lastTask,
RemoteAsyncOperation<RemoteExecutionResult> operation,
string initializationFileOpt,
bool isRestarting)
{
Debug.Assert(initializationFileOpt == null || PathUtilities.IsAbsolute(initializationFileOpt));
var state = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
try
{
// TODO (tomat): this is also done in CommonInteractiveEngine, perhaps we can pass the parsed command lines to here?
if (!isRestarting)
{
Console.Out.WriteLine(_replServiceProvider.Logo);
}
if (File.Exists(initializationFileOpt))
{
Console.Out.WriteLine(string.Format(FeaturesResources.Loading_context_from_0, Path.GetFileName(initializationFileOpt)));
var parser = _replServiceProvider.CommandLineParser;
// The base directory for relative paths is the directory that contains the .rsp file.
// Note that .rsp files included by this .rsp file will share the base directory (Dev10 behavior of csc/vbc).
var rspDirectory = Path.GetDirectoryName(initializationFileOpt);
var args = parser.Parse(new[] { "@" + initializationFileOpt }, rspDirectory, RuntimeEnvironment.GetRuntimeDirectory(), null);
foreach (var error in args.Errors)
{
var writer = (error.Severity == DiagnosticSeverity.Error) ? Console.Error : Console.Out;
writer.WriteLine(error.GetMessage(CultureInfo.CurrentCulture));
}
if (args.Errors.Length == 0)
{
var metadataResolver = CreateMetadataReferenceResolver(args.ReferencePaths, rspDirectory);
var sourceResolver = CreateSourceReferenceResolver(args.SourcePaths, rspDirectory);
var metadataReferences = new List<PortableExecutableReference>();
foreach (CommandLineReference cmdLineReference in args.MetadataReferences)
{
// interactive command line parser doesn't accept modules or linked assemblies
Debug.Assert(cmdLineReference.Properties.Kind == MetadataImageKind.Assembly && !cmdLineReference.Properties.EmbedInteropTypes);
var resolvedReferences = metadataResolver.ResolveReference(cmdLineReference.Reference, baseFilePath: null, properties: MetadataReferenceProperties.Assembly);
if (!resolvedReferences.IsDefaultOrEmpty)
{
metadataReferences.AddRange(resolvedReferences);
}
}
var scriptPathOpt = args.SourceFiles.IsEmpty ? null : args.SourceFiles[0].Path;
var rspState = new EvaluationState(
state.ScriptStateOpt,
state.ScriptOptions.
WithFilePath(scriptPathOpt).
WithReferences(metadataReferences).
WithImports(CommandLineHelpers.GetImports(args)).
WithMetadataResolver(metadataResolver).
WithSourceResolver(sourceResolver),
args.SourcePaths,
args.ReferencePaths,
rspDirectory);
_globals.ReferencePaths.Clear();
_globals.ReferencePaths.AddRange(args.ReferencePaths);
_globals.SourcePaths.Clear();
_globals.SourcePaths.AddRange(args.SourcePaths);
_globals.Args.AddRange(args.ScriptArguments);
if (scriptPathOpt != null)
{
var newScriptState = await TryExecuteFileAsync(rspState, scriptPathOpt).ConfigureAwait(false);
if (newScriptState != null)
{
// remove references and imports from the options, they have been applied and will be inherited from now on:
rspState = rspState.
WithScriptState(newScriptState).
WithOptions(rspState.ScriptOptions.RemoveImportsAndReferences());
}
}
state = rspState;
}
}
if (!isRestarting)
{
Console.Out.WriteLine(FeaturesResources.Type_Sharphelp_for_more_information);
}
}
//.........这里部分代码省略.........
示例6: AddReferenceAsync
public void AddReferenceAsync(RemoteAsyncOperation<bool> operation, string reference)
{
Debug.Assert(operation != null);
Debug.Assert(reference != null);
lock (_lastTaskGuard)
{
_lastTask = AddReferenceAsync(_lastTask, operation, reference);
}
}
示例7: ExecuteAsync
public void ExecuteAsync(RemoteAsyncOperation<RemoteExecutionResult> operation, string text)
{
Debug.Assert(operation != null);
Debug.Assert(text != null);
lock (_lastTaskGuard)
{
_lastTask = ExecuteAsync(_lastTask, operation, text);
}
}
示例8: InitializeContextAsync
public void InitializeContextAsync(RemoteAsyncOperation<RemoteExecutionResult> operation, string initializationFile, bool isRestarting)
{
Debug.Assert(operation != null);
var success = false;
try
{
InitializeContext(initializationFile, isRestarting);
success = true;
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
CompleteExecution(operation, success);
}
}
示例9: AddReferenceAsync
public void AddReferenceAsync(RemoteAsyncOperation<bool> operation, string reference)
{
Debug.Assert(operation != null);
Debug.Assert(reference != null);
var success = false;
try
{
// TODO (tomat): This lock blocks all other session operations.
// We should be able to run multiple assembly resolutions and code execution in parallel.
string fullPath;
lock (_sessionGuard)
{
fullPath = ResolveReferencePath(reference, baseFilePath: null);
if (fullPath != null)
{
success = LoadReference(fullPath, suppressWarnings: false, addReference: true);
}
}
if (fullPath == null)
{
Console.Error.WriteLine(string.Format(FeaturesResources.CannotResolveReference, reference));
}
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
operation.Completed(success);
}
}
示例10: ExecuteFileAsync
private async Task<TaskResult> ExecuteFileAsync(
RemoteAsyncOperation<RemoteExecutionResult> operation,
Task<TaskResult> lastTask,
Func<ScriptOptions, string> getFullPath)
{
var result = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
var success = false;
try
{
var fullPath = getFullPath(result.Options);
var executeResult = await ExecuteFileAsync(result, fullPath).ConfigureAwait(false);
result = executeResult.Result;
success = executeResult.Success;
}
finally
{
result = CompleteExecution(result, operation, success);
}
return result;
}
示例11: SetPathsAsync
public void SetPathsAsync(
RemoteAsyncOperation<object> operation,
string[] referenceSearchPaths,
string[] sourceSearchPaths,
string baseDirectory)
{
Debug.Assert(operation != null);
Debug.Assert(referenceSearchPaths != null);
Debug.Assert(sourceSearchPaths != null);
Debug.Assert(baseDirectory != null);
lock (_sessionGuard)
{
_hostObject.ReferencePaths.Clear();
_hostObject.ReferencePaths.AddRange(referenceSearchPaths);
_options = _options.WithSearchPaths(referenceSearchPaths).WithBaseDirectory(baseDirectory);
_hostObject.SourcePaths.Clear();
_hostObject.SourcePaths.AddRange(sourceSearchPaths);
_sourceSearchPaths = sourceSearchPaths.AsImmutable();
Directory.SetCurrentDirectory(baseDirectory);
}
operation.Completed(null);
}
示例12: InitializeContextAsync
/// <summary>
/// Loads references, set options and execute files specified in the initialization file.
/// Also prints logo unless <paramref name="isRestarting"/> is true.
/// </summary>
private async Task<TaskResult> InitializeContextAsync(
Task<TaskResult> lastTask,
RemoteAsyncOperation<RemoteExecutionResult> operation,
string initializationFileOpt,
bool isRestarting)
{
Debug.Assert(initializationFileOpt == null || PathUtilities.IsAbsolute(initializationFileOpt));
var result = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
try
{
// TODO (tomat): this is also done in CommonInteractiveEngine, perhaps we can pass the parsed command lines to here?
if (!isRestarting)
{
Console.Out.WriteLine(_repl.GetLogo());
}
if (File.Exists(initializationFileOpt))
{
Console.Out.WriteLine(string.Format(FeaturesResources.LoadingContextFrom, Path.GetFileName(initializationFileOpt)));
var parser = _repl.GetCommandLineParser();
// The base directory for relative paths is the directory that contains the .rsp file.
// Note that .rsp files included by this .rsp file will share the base directory (Dev10 behavior of csc/vbc).
var rspDirectory = Path.GetDirectoryName(initializationFileOpt);
var args = parser.Parse(new[] { "@" + initializationFileOpt }, rspDirectory, RuntimeEnvironment.GetRuntimeDirectory(), null /* TODO: pass a valid value*/);
foreach (var error in args.Errors)
{
var writer = (error.Severity == DiagnosticSeverity.Error) ? Console.Error : Console.Out;
writer.WriteLine(error.GetMessage(CultureInfo.CurrentCulture));
}
if (args.Errors.Length == 0)
{
// TODO (tomat): other arguments
// TODO (tomat): parse options
var referencePaths = args.ReferencePaths;
result = result.With(result.Options.AddSearchPaths(referencePaths));
_hostObject.ReferencePaths.Clear();
_hostObject.ReferencePaths.AddRange(referencePaths);
// TODO (tomat): consolidate with other reference resolving
foreach (CommandLineReference cmdLineReference in args.MetadataReferences)
{
// interactive command line parser doesn't accept modules or linked assemblies
Debug.Assert(cmdLineReference.Properties.Kind == MetadataImageKind.Assembly && !cmdLineReference.Properties.EmbedInteropTypes);
var options = result.Options;
string fullPath = ResolveReferencePath(options, cmdLineReference.Reference, baseFilePath: null);
LoadReference(fullPath, suppressWarnings: true, addReference: true, options: ref options);
result = result.With(options);
}
foreach (CommandLineSourceFile file in args.SourceFiles)
{
// execute all files as scripts (matches csi/vbi semantics)
string fullPath = ResolveRelativePath(file.Path, rspDirectory, displayPath: true);
if (fullPath != null)
{
var executeResult = await ExecuteFileAsync(result, fullPath).ConfigureAwait(false);
result = executeResult.Result;
}
}
}
}
if (!isRestarting)
{
Console.Out.WriteLine(FeaturesResources.TypeHelpForMoreInformation);
}
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
result = CompleteExecution(result, operation, true);
}
return result;
}
示例13: ExecuteAsync
private async Task<TaskResult> ExecuteAsync(Task<TaskResult> lastTask, RemoteAsyncOperation<RemoteExecutionResult> operation, string text)
{
var result = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
var success = false;
try
{
Script<object> script;
try
{
var options = result.Options;
var state = result.State;
script = Compile(state, text, null, ref options);
result = new TaskResult(options, state);
}
catch (CompilationErrorException e)
{
DisplayInteractiveErrors(e.Diagnostics, Console.Error);
script = null;
}
if (script != null)
{
success = true; // successful if compiled
var executeResult = await ExecuteOnUIThread(result, script).ConfigureAwait(false);
result = executeResult.Result;
if (executeResult.Success)
{
bool hasValue;
var resultType = script.GetCompilation().GetSubmissionResultType(out hasValue);
if (hasValue)
{
if (resultType != null && resultType.SpecialType == SpecialType.System_Void)
{
Console.Out.WriteLine(_objectFormatter.VoidDisplayString);
}
else
{
Console.Out.WriteLine(_objectFormatter.FormatObject(executeResult.Value, _formattingOptions));
}
}
}
}
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
result = CompleteExecution(result, operation, success);
}
return result;
}
示例14: ExecuteAsync
public void ExecuteAsync(RemoteAsyncOperation<RemoteExecutionResult> operation, string text)
{
Debug.Assert(operation != null);
Debug.Assert(text != null);
var success = false;
try
{
success = Execute(text);
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
CompleteExecution(operation, success);
}
}
示例15: ExecuteFileAsync
public void ExecuteFileAsync(RemoteAsyncOperation<RemoteExecutionResult> operation, string path)
{
Debug.Assert(operation != null);
Debug.Assert(path != null);
string fullPath = null;
bool success = false;
try
{
fullPath = ResolveRelativePath(path, _options.BaseDirectory, displayPath: false);
success = fullPath != null && ExecuteFile(fullPath);
}
catch (Exception e)
{
ReportUnhandledException(e);
}
finally
{
CompleteExecution(operation, success, fullPath);
}
}