本文整理汇总了C#中OptionSet.WithChangedOption方法的典型用法代码示例。如果您正苦于以下问题:C# OptionSet.WithChangedOption方法的具体用法?C# OptionSet.WithChangedOption怎么用?C# OptionSet.WithChangedOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionSet
的用法示例。
在下文中一共展示了OptionSet.WithChangedOption方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyOptions
static OptionSet ApplyOptions(OptionSet previousOptions, string comments)
{
var commentLines = new List<string>();
if (!string.IsNullOrEmpty(comments))
{
using (var reader = new StringReader(comments))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (String.IsNullOrEmpty(line))
{
continue;
}
commentLines.Add(line.Replace("// ", String.Empty));
}
}
}
return previousOptions.WithChangedOption(HeaderCommentStyleRule.HeaderComments, commentLines);
}
示例2: GetUpdatedRecommendationOptions
protected OptionSet GetUpdatedRecommendationOptions(OptionSet options, string language)
{
var filterOutOfScopeLocals = options.GetOption(CompletionControllerOptions.FilterOutOfScopeLocals);
var hideAdvancedMembers = options.GetOption(CompletionOptions.HideAdvancedMembers, language);
return options
.WithChangedOption(RecommendationOptions.FilterOutOfScopeLocals, language, filterOutOfScopeLocals)
.WithChangedOption(RecommendationOptions.HideAdvancedMembers, language, hideAdvancedMembers);
}
示例3: ApplyOptions
static OptionSet ApplyOptions(OptionSet options, bool explicitAccessModifier)
{
return options.WithChangedOption(
DefaultAccessModifierStyleRule.ExplicitAccessModifier, explicitAccessModifier);
}
示例4: TryNavigateToSymbol
public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet options, CancellationToken cancellationToken)
{
if (project == null || symbol == null)
{
return false;
}
options = options ?? project.Solution.Workspace.Options;
symbol = symbol.OriginalDefinition;
// Prefer visible source locations if possible.
var sourceLocations = symbol.Locations.Where(loc => loc.IsInSource);
var visibleSourceLocations = sourceLocations.Where(loc => loc.IsVisibleSourceLocation());
var sourceLocation = visibleSourceLocations.FirstOrDefault() ?? sourceLocations.FirstOrDefault();
if (sourceLocation != null)
{
var targetDocument = project.Solution.GetDocument(sourceLocation.SourceTree);
if (targetDocument != null)
{
var editorWorkspace = targetDocument.Project.Solution.Workspace;
var navigationService = editorWorkspace.Services.GetService<IDocumentNavigationService>();
return navigationService.TryNavigateToSpan(editorWorkspace, targetDocument.Id, sourceLocation.SourceSpan, options);
}
}
// We don't have a source document, so show the Metadata as Source view in a preview tab.
var metadataLocation = symbol.Locations.Where(loc => loc.IsInMetadata).FirstOrDefault();
if (metadataLocation == null || !_metadataAsSourceFileService.IsNavigableMetadataSymbol(symbol))
{
return false;
}
// Should we prefer navigating to the Object Browser over metadata-as-source?
if (options.GetOption(VisualStudioNavigationOptions.NavigateToObjectBrowser, project.Language))
{
var libraryService = project.LanguageServices.GetService<ILibraryService>();
if (libraryService == null)
{
return false;
}
var compilation = project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var navInfo = libraryService.NavInfoFactory.CreateForSymbol(symbol, project, compilation);
if (navInfo == null)
{
navInfo = libraryService.NavInfoFactory.CreateForProject(project);
}
if (navInfo != null)
{
var navigationTool = _serviceProvider.GetService<SVsObjBrowser, IVsNavigationTool>();
return navigationTool.NavigateToNavInfo(navInfo) == VSConstants.S_OK;
}
// Note: we'll fallback to Metadata-As-Source if we fail to get IVsNavInfo, but that should never happen.
}
// Generate new source or retrieve existing source for the symbol in question
var result = _metadataAsSourceFileService.GetGeneratedFileAsync(project, symbol, cancellationToken).WaitAndGetResult(cancellationToken);
var vsRunningDocumentTable4 = _serviceProvider.GetService<SVsRunningDocumentTable, IVsRunningDocumentTable4>();
var fileAlreadyOpen = vsRunningDocumentTable4.IsMonikerValid(result.FilePath);
var openDocumentService = _serviceProvider.GetService<SVsUIShellOpenDocument, IVsUIShellOpenDocument>();
IVsUIHierarchy hierarchy;
uint itemId;
IOleServiceProvider localServiceProvider;
IVsWindowFrame windowFrame;
openDocumentService.OpenDocumentViaProject(result.FilePath, VSConstants.LOGVIEWID.TextView_guid, out localServiceProvider, out hierarchy, out itemId, out windowFrame);
var documentCookie = vsRunningDocumentTable4.GetDocumentCookie(result.FilePath);
var vsTextBuffer = (IVsTextBuffer)vsRunningDocumentTable4.GetDocumentData(documentCookie);
var textBuffer = _editorAdaptersFactory.GetDataBuffer(vsTextBuffer);
if (!fileAlreadyOpen)
{
ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_IsProvisional, true));
ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_OverrideCaption, result.DocumentTitle));
ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_OverrideToolTip, result.DocumentTooltip));
}
windowFrame.Show();
var openedDocument = textBuffer.AsTextContainer().GetRelatedDocuments().FirstOrDefault();
if (openedDocument != null)
{
var editorWorkspace = openedDocument.Project.Solution.Workspace;
var navigationService = editorWorkspace.Services.GetService<IDocumentNavigationService>();
return navigationService.TryNavigateToSpan(
workspace: editorWorkspace,
documentId: openedDocument.Id,
textSpan: result.IdentifierLocation.SourceSpan,
options: options.WithChangedOption(NavigationOptions.PreferProvisionalTab, true));
}
//.........这里部分代码省略.........
示例5: ApplyForEachOption
static OptionSet ApplyForEachOption(OptionSet options, bool value = true)
{
return options.WithChangedOption(AmbiguousImplicitVariableStyleRule.EnforceForEachStatements, value);
}
示例6: SetOptions
private static OptionSet SetOptions(OptionSet options)
{
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInAccessors, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInAnonymousMethods, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInAnonymousTypes, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInLambdaExpressionBody, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInMethods, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInProperties, true);
options = options.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInTypes, true);
options = options.WithChangedOption(SimplificationOptions.PreferAliasToQualification, false);
options = options.WithChangedOption(SimplificationOptions.PreferOmittingModuleNamesInQualification, false);
options = options.WithChangedOption(SimplificationOptions.PreferImplicitTypeInference, false);
options = options.WithChangedOption(SimplificationOptions.PreferImplicitTypeInLocalDeclaration, false);
options = options.WithChangedOption(SimplificationOptions.AllowSimplificationToGenericType, true);
options = options.WithChangedOption(SimplificationOptions.AllowSimplificationToBaseType, false);
options = options.WithChangedOption(SimplificationOptions.QualifyMemberAccessWithThisOrMe, LanguageNames.CSharp, true);
options = options.WithChangedOption(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, LanguageNames.CSharp, false);
options = options.WithChangedOption(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, LanguageNames.CSharp, false);
return options;
}
示例7: TryGoToDefinition
private static bool TryGoToDefinition(
ImmutableArray<INavigableItem> navigableItems,
string title,
OptionSet options,
IEnumerable<Lazy<INavigableItemsPresenter>> presenters,
bool throwOnHiddenDefinition)
{
Contract.ThrowIfNull(options);
// If we have a single location, then just navigate to it.
if (navigableItems.Length == 1 && navigableItems[0].Document != null)
{
var firstItem = navigableItems[0];
var workspace = firstItem.Document.Project.Solution.Workspace;
var navigationService = workspace.Services.GetService<IDocumentNavigationService>();
if (navigationService.CanNavigateToSpan(workspace, firstItem.Document.Id, firstItem.SourceSpan))
{
return navigationService.TryNavigateToSpan(
workspace,
documentId: firstItem.Document.Id,
textSpan: firstItem.SourceSpan,
options: options.WithChangedOption(NavigationOptions.PreferProvisionalTab, true));
}
else
{
if (throwOnHiddenDefinition)
{
const int E_FAIL = -2147467259;
throw new COMException(EditorFeaturesResources.TheDefinitionOfTheObjectIsHidden, E_FAIL);
}
else
{
return false;
}
}
}
else
{
// We have multiple viable source locations, so ask the host what to do. Most hosts
// will simply display the results to the user and allow them to choose where to
// go.
if (presenters.Any())
{
presenters.First().Value.DisplayResult(title, navigableItems);
return true;
}
return false;
}
}
示例8: ApplyOptions
static OptionSet ApplyOptions(OptionSet options, bool systemUsingsFirst)
{
return options.WithChangedOption(OrderedUsingsStyleRule.SystemUsingsFirst, value: systemUsingsFirst);
}