本文整理汇总了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;
}
}
示例2: InitEditor
protected MainForm InitEditor()
{
var workspace = new Workspace();
MainForm main = new MainForm(workspace);
DualityEditorApp.Init(main, this.recover, workspace);
return main;
}
示例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();
}
示例4: LanguageServiceTests
public LanguageServiceTests()
{
this.workspace = new Workspace();
this.powerShellContext = new PowerShellContext();
this.languageService = new LanguageService(this.powerShellContext);
}
示例5: Apply
public override void Apply(Workspace workspace, CancellationToken cancellationToken)
{
if (workspace.CanOpenDocuments)
{
workspace.OpenDocument(this.documentId, this.activate);
}
}
示例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);
}
}
}
示例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);
}
示例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)
{
}
示例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;
}
示例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;
}
示例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
}
}
示例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));
}
示例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));
}
示例14: Create
public object Create([FromBody] WorkspaceCreateModel model)
{
var workspace = new Workspace<IExtent>(model.name, model.annotation);
_workspaceCollection.AddWorkspace(workspace);
return new {success = true};
}
示例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;
}