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


C# Workspace类代码示例

本文整理汇总了C#中Workspace的典型用法代码示例。如果您正苦于以下问题:C# Workspace类的具体用法?C# Workspace怎么用?C# Workspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreateAsync

        public static async Task<RemoteHostClient> CreateAsync(
            Workspace workspace, CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, cancellationToken))
            {
                var primary = new HubClient("ManagedLanguage.IDE.RemoteHostClient");
                var remoteHostStream = await primary.RequestServiceAsync(WellKnownRemoteHostServices.RemoteHostService, cancellationToken).ConfigureAwait(false);

                var instance = new ServiceHubRemoteHostClient(workspace, primary, remoteHostStream);

                // make sure connection is done right
                var current = $"VS ({Process.GetCurrentProcess().Id})";
                var host = await instance._rpc.InvokeAsync<string>(WellKnownRemoteHostServices.RemoteHostService_Connect, current).ConfigureAwait(false);

                // TODO: change this to non fatal watson and make VS to use inproc implementation
                Contract.ThrowIfFalse(host == current.ToString());

                instance.Connected();

                // Create a workspace host to hear about workspace changes.  We'll 
                // remote those changes over to the remote side when they happen.
                RegisterWorkspaceHost(workspace, instance);

                // return instance
                return instance;
            }
        }
开发者ID:orthoxerox,项目名称:roslyn,代码行数:27,代码来源:ServiceHubRemoteHostClient.cs

示例2: InitEditor

 protected MainForm InitEditor()
 {
     var workspace = new Workspace();
     MainForm main = new MainForm(workspace);
     DualityEditorApp.Init(main, this.recover, workspace);
     return main;
 }
开发者ID:BraveSirAndrew,项目名称:duality,代码行数:7,代码来源:SplashScreen.cs

示例3: GetBingHelpMessage

        public static string GetBingHelpMessage(this Diagnostic diagnostic, Workspace workspace = null)
        {
            var option = GetCustomTypeInBingSearchOption(workspace);

            // We use the ENU version of the message for bing search.
            return option ? diagnostic.GetMessage(USCultureInfo) : diagnostic.Descriptor.GetBingHelpMessage();
        }
开发者ID:nemec,项目名称:roslyn,代码行数:7,代码来源:Extensions.cs

示例4: LanguageServiceTests

        public LanguageServiceTests()
        {
            this.workspace = new Workspace();

            this.powerShellContext = new PowerShellContext();
            this.languageService = new LanguageService(this.powerShellContext);
        }
开发者ID:juvchan,项目名称:PowerShellEditorServices,代码行数:7,代码来源:LanguageServiceTests.cs

示例5: Apply

 public override void Apply(Workspace workspace, CancellationToken cancellationToken)
 {
     if (workspace.CanOpenDocuments)
     {
         workspace.OpenDocument(this.documentId, this.activate);
     }
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:7,代码来源:OpenDocumentOperation.cs

示例6: SynchronizeWithBuildAsync

        public override async Task SynchronizeWithBuildAsync(Workspace workspace, ImmutableDictionary<ProjectId, ImmutableArray<DiagnosticData>> map)
        {
            if (!PreferBuildErrors(workspace))
            {
                // prefer live errors over build errors
                return;
            }

            var solution = workspace.CurrentSolution;
            foreach (var projectEntry in map)
            {
                var project = solution.GetProject(projectEntry.Key);
                if (project == null)
                {
                    continue;
                }

                var stateSets = _stateManager.CreateBuildOnlyProjectStateSet(project);
                var lookup = projectEntry.Value.ToLookup(d => d.DocumentId);

                // do project one first
                await SynchronizeWithBuildAsync(project, stateSets, lookup[null]).ConfigureAwait(false);

                foreach (var document in project.Documents)
                {
                    await SynchronizeWithBuildAsync(document, stateSets, lookup[document.Id]).ConfigureAwait(false);
                }
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:29,代码来源:DiagnosticIncrementalAnalyzer_BuildSynchronization.cs

示例7: CreateEngineAsync

        public static async Task<ISymbolSearchUpdateEngine> CreateEngineAsync(
            Workspace workspace, ISymbolSearchLogService logService, CancellationToken cancellationToken)
        {
            var outOfProcessAllowed = workspace.Options.GetOption(SymbolSearchOptions.OutOfProcessAllowed);
            if (outOfProcessAllowed)
            {
                var client = await workspace.GetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
                if (client != null)
                {
                    var emptySolution = workspace.CreateSolution(workspace.CurrentSolution.Id);

                    // We create a single session and use it for the entire lifetime of this process.
                    // That single session will be used to do all communication with the remote process.
                    // This is because each session will cause a new instance of the RemoteSymbolSearchUpdateEngine
                    // to be created on the remote side.  We only want one instance of that type.  The
                    // alternative is to make that type static variable on the remote side.  But that's
                    // much less clean and would make some of the state management much more complex.
                    var session = await client.CreateServiceSessionAsync(
                        WellKnownServiceHubServices.RemoteSymbolSearchUpdateEngine,
                        emptySolution, logService, cancellationToken).ConfigureAwait(false);

                    return new RemoteUpdateEngine(session);
                }
            }

            // Couldn't go out of proc.  Just do everything inside the current process.
            return new SymbolSearchUpdateEngine(logService);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:SymbolSearchUpdateEngineFactory.cs

示例8: DiagnosticData

 public DiagnosticData(
     string id,
     string category,
     string message,
     string enuMessageForBingSearch,
     DiagnosticSeverity severity,
     bool isEnabledByDefault,
     int warningLevel,
     Workspace workspace,
     ProjectId projectId,
     DocumentId documentId = null,
     TextSpan? span = null,
     string originalFilePath = null,
     int originalStartLine = 0,
     int originalStartColumn = 0,
     int originalEndLine = 0,
     int originalEndColumn = 0,
     string title = null,
     string description = null,
     string helpLink = null) :
         this(
             id, category, message, enuMessageForBingSearch,
             severity, severity, isEnabledByDefault, warningLevel,
             ImmutableArray<string>.Empty, ImmutableDictionary<string, string>.Empty,
             workspace, projectId, documentId, span,
             null, originalStartLine, originalStartColumn, originalEndLine, originalEndColumn,
             originalFilePath, originalStartLine, originalStartColumn, originalEndLine, originalEndColumn,
             title, description, helpLink)
 {
 }
开发者ID:reidwooten99apps,项目名称:roslyn,代码行数:30,代码来源:DiagnosticData.cs

示例9: GetSolutionSize

 /// <summary>
 /// Get approximate solution size at the point of call.
 /// 
 /// This API is not supposed to return 100% accurate size. 
 /// 
 /// if a feature require 100% accurate size, use Solution to calculate it. this API is supposed to
 /// lazy and very cheap on answering that question.
 /// </summary>
 public long GetSolutionSize(Workspace workspace, SolutionId solutionId)
 {
     var service = workspace.Services.GetService<IPersistentStorageLocationService>();
     return service.IsSupported(workspace)
         ? _tracker.GetSolutionSize(solutionId)
         : -1;
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:15,代码来源:SolutionSizeTracker.cs

示例10: GetSymbolsTouchingPosition

        internal static IEnumerable<ISymbol> GetSymbolsTouchingPosition(
            int position, SemanticModel semanticModel, Workspace workspace, CancellationToken cancellationToken)
        {
            var bindableToken = semanticModel.SyntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true);
            var semanticInfo = semanticModel.GetSemanticInfo(bindableToken, workspace, cancellationToken);
            var symbols = semanticInfo.DeclaredSymbol != null
                ? ImmutableArray.Create<ISymbol>(semanticInfo.DeclaredSymbol)
                : semanticInfo.GetSymbols(includeType: false);

            // if there are more than one symbol, then remove the alias symbols.
            // When using (not declaring) an alias, the alias symbol and the target symbol are returned
            // by GetSymbols
            if (symbols.Length > 1)
            {
                symbols = symbols.WhereAsArray(s => s.Kind != SymbolKind.Alias);
            }

            if (symbols.Length == 0)
            {
                var info = semanticModel.GetSymbolInfo(bindableToken, cancellationToken);
                if (info.CandidateReason == CandidateReason.MemberGroup)
                {
                    return info.CandidateSymbols;
                }
            }

            return symbols;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:RenameUtilities.cs

示例11: Register

        public async void Register(Workspace workspace)
        {
            try
            {
                var workerBackOffTimeSpanInMS = workspace.Options.GetOption(InternalSolutionCrawlerOptions.PreviewBackOffTimeSpanInMS);

                var analyzer = _provider.CreateIncrementalAnalyzer(workspace);
                var source = s_cancellationTokens.GetValue(workspace, _ => new CancellationTokenSource());

                var solution = workspace.CurrentSolution;
                foreach (var documentId in workspace.GetOpenDocumentIds())
                {
                    var document = solution.GetDocument(documentId);
                    if (document == null)
                    {
                        continue;
                    }

                    // delay analyzing
                    await Task.Delay(workerBackOffTimeSpanInMS).ConfigureAwait(false);

                    // do actual analysis
                    await analyzer.AnalyzeSyntaxAsync(document, source.Token).ConfigureAwait(false);
                    await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, cancellationToken: source.Token).ConfigureAwait(false);

                    // don't call project one.
                }
            }
            catch (OperationCanceledException)
            {
                // do nothing
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:33,代码来源:PreviewSolutionCrawlerRegistrationService.cs

示例12: Add

        public void Add(string key, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = Shell.GetCurrentPath();
            }

            if (string.IsNullOrEmpty(key)) throw new Exception("Key is required");

            Workspace workspace = new Workspace()
            {
                Key = key,
                Path = path
            };

            //try to get if existing
            var workspaceData = Data.GetWorkspace(workspace.Key);

            if (workspaceData != null)
            {
                Data.UpdateWorkspace(workspace);
            }
            else
            {
                Data.CreateWorkspace(workspace);
            }

            Shell.Write(string.Format("[{0}] '{1}' added.", workspace.Key, workspace.Path));
        }
开发者ID:netxph,项目名称:redshells,代码行数:29,代码来源:WorkspaceModel.cs

示例13: GenerateConstructorDeclaration

        internal static ConstructorDeclarationSyntax GenerateConstructorDeclaration(
            IMethodSymbol constructor, CodeGenerationDestination destination, 
            Workspace workspace, CodeGenerationOptions options, ParseOptions parseOptions)
        {
            options = options ?? CodeGenerationOptions.Default;

            var reusableSyntax = GetReuseableSyntaxNodeForSymbol<ConstructorDeclarationSyntax>(constructor, options);
            if (reusableSyntax != null)
            {
                return reusableSyntax;
            }

            bool hasNoBody = !options.GenerateMethodBodies;

            var declaration = SyntaxFactory.ConstructorDeclaration(
                attributeLists: AttributeGenerator.GenerateAttributeLists(constructor.GetAttributes(), options),
                modifiers: GenerateModifiers(constructor, options),
                identifier: CodeGenerationConstructorInfo.GetTypeName(constructor).ToIdentifierToken(),
                parameterList: ParameterGenerator.GenerateParameterList(constructor.Parameters, isExplicit: false, options: options),
                initializer: GenerateConstructorInitializer(constructor),
                body: hasNoBody ? null : GenerateBlock(constructor),
                semicolonToken: hasNoBody ? SyntaxFactory.Token(SyntaxKind.SemicolonToken) : default(SyntaxToken));

            declaration = UseExpressionBodyIfDesired(workspace, declaration, parseOptions);

            return AddCleanupAnnotationsTo(
                ConditionallyAddDocumentationCommentTo(declaration, constructor, options));
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:ConstructorGenerator.cs

示例14: Create

        public object Create([FromBody] WorkspaceCreateModel model)
        {
            var workspace = new Workspace<IExtent>(model.name, model.annotation);
            _workspaceCollection.AddWorkspace(workspace);

            return new {success = true};
        }
开发者ID:mbrenn,项目名称:datenmeister-new,代码行数:7,代码来源:WorkspaceController.cs

示例15: GetEntityOfInterestSpan

        internal static LinePositionSpan GetEntityOfInterestSpan(ISymbol symbol, Workspace workspace, Location identifierLocation, CancellationToken cancellationToken)
        {
            // This is called on a background thread, but since we don't have proper asynchrony we must block
            var root = identifierLocation.SourceTree.GetRoot(cancellationToken);
            var node = root.FindToken(identifierLocation.SourceSpan.Start).Parent;

            var syntaxFactsService = workspace.Services.GetLanguageServices(root.Language).GetService<ISyntaxFactsService>();

            switch (symbol.Kind)
            {
                case SymbolKind.Event:
                case SymbolKind.Field:
                case SymbolKind.Method:
                case SymbolKind.Property:
                    node = node.FirstAncestorOrSelf<SyntaxNode>(syntaxFactsService.IsMethodLevelMember) ?? node;
                    break;

                case SymbolKind.NamedType:
                case SymbolKind.Namespace:
                    node = node.FirstAncestorOrSelf<SyntaxNode>(syntaxFactsService.IsTopLevelNodeWithMembers) ?? node;
                    break;
            }

            return identifierLocation.SourceTree.GetLocation(node.Span).GetLineSpan().Span;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:PeekHelpers.cs


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