当前位置: 首页>>代码示例>>C#>>正文


C# RemoteAsyncOperation.Completed方法代码示例

本文整理汇总了C#中RemoteAsyncOperation.Completed方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteAsyncOperation.Completed方法的具体用法?C# RemoteAsyncOperation.Completed怎么用?C# RemoteAsyncOperation.Completed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RemoteAsyncOperation的用法示例。


在下文中一共展示了RemoteAsyncOperation.Completed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddReferenceAsync

            private async Task<EvaluationState> AddReferenceAsync(Task<EvaluationState> lastTask, RemoteAsyncOperation<bool> operation, string reference)
            {
                var state = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
                bool success = false;

                try
                {
                    var resolvedReferences = state.ScriptOptions.MetadataResolver.ResolveReference(reference, baseFilePath: null, properties: MetadataReferenceProperties.Assembly);
                    if (!resolvedReferences.IsDefaultOrEmpty)
                    {
                        state = state.WithOptions(state.ScriptOptions.AddReferences(resolvedReferences));
                        success = true;
                    }
                    else
                    {
                        Console.Error.WriteLine(string.Format(FeaturesResources.Cannot_resolve_reference_0, reference));
                    }
                }
                catch (Exception e)
                {
                    ReportUnhandledException(e);
                }
                finally
                {
                    operation.Completed(success);
                }

                return state;
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:InteractiveHost.Service.cs

示例2: CompleteExecution

            private EvaluationState CompleteExecution(EvaluationState state, RemoteAsyncOperation<RemoteExecutionResult> operation, bool success)
            {
                // send any updates to the host object and current directory back to the client:
                var currentSourcePaths = _globals.SourcePaths.ToArray();
                var currentReferencePaths = _globals.ReferencePaths.ToArray();
                var currentWorkingDirectory = Directory.GetCurrentDirectory();

                var changedSourcePaths = currentSourcePaths.SequenceEqual(state.SourceSearchPaths) ? null : currentSourcePaths;
                var changedReferencePaths = currentReferencePaths.SequenceEqual(state.ReferenceSearchPaths) ? null : currentReferencePaths;
                var changedWorkingDirectory = currentWorkingDirectory == state.WorkingDirectory ? null : currentWorkingDirectory;

                operation.Completed(new RemoteExecutionResult(success, changedSourcePaths, changedReferencePaths, changedWorkingDirectory));

                // no changes in resolvers:
                if (changedReferencePaths == null && changedSourcePaths == null && changedWorkingDirectory == null)
                {
                    return state;
                }

                var newSourcePaths = ImmutableArray.CreateRange(currentSourcePaths);
                var newReferencePaths = ImmutableArray.CreateRange(currentReferencePaths);
                var newWorkingDirectory = currentWorkingDirectory;

                ScriptOptions newOptions = state.ScriptOptions;
                if (changedReferencePaths != null || changedWorkingDirectory != null)
                {
                    newOptions = newOptions.WithMetadataResolver(CreateMetadataReferenceResolver(newReferencePaths, newWorkingDirectory));
                }

                if (changedSourcePaths != null || changedWorkingDirectory != null)
                {
                    newOptions = newOptions.WithSourceResolver(CreateSourceReferenceResolver(newSourcePaths, newWorkingDirectory));
                }

                return new EvaluationState(
                    state.ScriptStateOpt,
                    newOptions,
                    newSourcePaths,
                    newReferencePaths,
                    workingDirectory: newWorkingDirectory);
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:41,代码来源:InteractiveHost.Service.cs

示例3: CompleteExecution

            private void CompleteExecution(RemoteAsyncOperation<RemoteExecutionResult> operation, bool success, string resolvedPath = null)
            {
                // TODO (tomat): we should be resetting this info just before the execution to ensure that the services see the same
                // as the next execution.

                // send any updates to the host object and current directory back to the client:
                var newSourcePaths = _hostObject.SourcePaths.List.GetNewContent();
                var newReferencePaths = _hostObject.ReferencePaths.List.GetNewContent();
                var currentDirectory = Directory.GetCurrentDirectory();
                var oldWorkingDirectory = _options.BaseDirectory;
                var newWorkingDirectory = (oldWorkingDirectory != currentDirectory) ? currentDirectory : null;

                // update local search paths, the client updates theirs on operation completion:

                if (newSourcePaths != null)
                {
                    _sourceSearchPaths = newSourcePaths.AsImmutable();
                }

                if (newReferencePaths != null)
                {
                    _options = _options.WithSearchPaths(newReferencePaths);
                }

                _options = _options.WithBaseDirectory(currentDirectory);

                operation.Completed(new RemoteExecutionResult(success, newSourcePaths, newReferencePaths, newWorkingDirectory, resolvedPath));
            }
开发者ID:WiiGe,项目名称:roslyn,代码行数:28,代码来源:InteractiveHost.Service.cs

示例4: 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);
                }
            }
开发者ID:WiiGe,项目名称:roslyn,代码行数:34,代码来源:InteractiveHost.Service.cs

示例5: 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);
            }
开发者ID:WiiGe,项目名称:roslyn,代码行数:26,代码来源:InteractiveHost.Service.cs

示例6: 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);
 }
开发者ID:noahstein,项目名称:roslyn,代码行数:27,代码来源:InteractiveHost.Service.cs

示例7: SetPathsAsync

            private async Task<TaskResult> SetPathsAsync(
                Task<TaskResult> lastTask,
                RemoteAsyncOperation<object> operation,
                string[] referenceSearchPaths,
                string[] sourceSearchPaths,
                string baseDirectory)
            {
                var result = await ReportUnhandledExceptionIfAny(lastTask).ConfigureAwait(false);
                var options = result.Options;
                try
                {
                    Directory.SetCurrentDirectory(baseDirectory);

                    _hostObject.ReferencePaths.Clear();
                    _hostObject.ReferencePaths.AddRange(referenceSearchPaths);
                    options = options.WithSearchPaths(referenceSearchPaths).WithBaseDirectory(baseDirectory);

                    _hostObject.SourcePaths.Clear();
                    _hostObject.SourcePaths.AddRange(sourceSearchPaths);
                    _sourceSearchPaths = sourceSearchPaths.AsImmutable();
                }
                finally
                {
                    operation.Completed(null);
                }
                return result.With(options);
            }
开发者ID:noahstein,项目名称:roslyn,代码行数:27,代码来源:InteractiveHost.Service.cs


注:本文中的RemoteAsyncOperation.Completed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。