本文整理汇总了C#中OptionSet.GetOption方法的典型用法代码示例。如果您正苦于以下问题:C# OptionSet.GetOption方法的具体用法?C# OptionSet.GetOption怎么用?C# OptionSet.GetOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionSet
的用法示例。
在下文中一共展示了OptionSet.GetOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameLocationSet
private RenameLocationSet(ISymbol symbol, Solution solution, OptionSet optionSet, SearchResult originalSymbolResult, List<SearchResult> overloadsResult, IEnumerable<RenameLocation> stringsResult, IEnumerable<RenameLocation> commentsResult)
{
_symbol = symbol;
_solution = solution;
_optionSet = optionSet;
_originalSymbolResult = originalSymbolResult;
_overloadsResult = overloadsResult;
_stringsResult = stringsResult;
_commentsResult = commentsResult;
var mergedLocations = new HashSet<RenameLocation>();
var mergedReferencedSymbols = new List<ISymbol>();
var mergedImplicitLocations = new List<ReferenceLocation>();
if (optionSet.GetOption(RenameOptions.RenameInStrings))
{
mergedLocations.AddRange(stringsResult);
}
if (optionSet.GetOption(RenameOptions.RenameInComments))
{
mergedLocations.AddRange(commentsResult);
}
var overloadsToMerge = (optionSet.GetOption(RenameOptions.RenameOverloads) ? overloadsResult : null) ?? SpecializedCollections.EmptyEnumerable<SearchResult>();
foreach (var result in overloadsToMerge.Concat(originalSymbolResult))
{
mergedLocations.AddRange(result.Locations);
mergedImplicitLocations.AddRange(result.ImplicitLocations);
mergedReferencedSymbols.AddRange(result.ReferencedSymbols);
}
_mergedResult = new SearchResult(mergedLocations, mergedImplicitLocations, mergedReferencedSymbols);
}
示例2: ShouldUseSmartTokenFormatterInsteadOfIndenter
public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter(
IEnumerable<IFormattingRule> formattingRules,
CompilationUnitSyntax root,
TextLine line,
OptionSet optionSet,
CancellationToken cancellationToken)
{
Contract.ThrowIfNull(formattingRules);
Contract.ThrowIfNull(root);
if (!optionSet.GetOption(FeatureOnOffOptions.AutoFormattingOnReturn, LanguageNames.CSharp))
{
return false;
}
if (optionSet.GetOption(FormattingOptions.SmartIndent, LanguageNames.CSharp) != FormattingOptions.IndentStyle.Smart)
{
return false;
}
var firstNonWhitespacePosition = line.GetFirstNonWhitespacePosition();
if (!firstNonWhitespacePosition.HasValue)
{
return false;
}
var token = root.FindToken(firstNonWhitespacePosition.Value);
if (token.IsKind(SyntaxKind.None) ||
token.SpanStart != firstNonWhitespacePosition)
{
return false;
}
// first see whether there is a line operation for current token
var previousToken = token.GetPreviousToken(includeZeroWidth: true);
// only use smart token formatter when we have two visible tokens.
if (previousToken.Kind() == SyntaxKind.None || previousToken.IsMissing)
{
return false;
}
var lineOperation = FormattingOperations.GetAdjustNewLinesOperation(formattingRules, previousToken, token, optionSet);
if (lineOperation == null || lineOperation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine)
{
// no indentation operation, nothing to do for smart token formatter
return false;
}
// We're pressing enter between two tokens, have the formatter figure out hte appropriate
// indentation.
return true;
}
示例3: FindRenameLocationsAsync
public async Task<IInlineRenameLocationSet> FindRenameLocationsAsync(OptionSet optionSet, CancellationToken cancellationToken)
{
var references = new List<InlineRenameLocation>();
IList<DocumentSpan> renameLocations = await _renameInfo.FindRenameLocationsAsync(
renameInStrings: optionSet.GetOption(RenameOptions.RenameInStrings),
renameInComments: optionSet.GetOption(RenameOptions.RenameInComments),
cancellationToken: cancellationToken).ConfigureAwait(false);
references.AddRange(renameLocations.Select(ds => new InlineRenameLocation(ds.Document, ds.TextSpan)));
return new InlineRenameLocationSet(_renameInfo, _document.Project.Solution, references);
}
示例4: GetRecommendedSymbolsAtPositionWorkerAsync
protected override Task<Tuple<ImmutableArray<ISymbol>, SyntaxContext>> GetRecommendedSymbolsAtPositionWorkerAsync(
Workspace workspace, SemanticModel semanticModel, int position, OptionSet options, CancellationToken cancellationToken)
{
var context = CSharpSyntaxContext.CreateContext(workspace, semanticModel, position, cancellationToken);
var filterOutOfScopeLocals = options.GetOption(RecommendationOptions.FilterOutOfScopeLocals, semanticModel.Language);
var symbols = GetSymbolsWorker(context, filterOutOfScopeLocals, cancellationToken);
var hideAdvancedMembers = options.GetOption(RecommendationOptions.HideAdvancedMembers, semanticModel.Language);
symbols = symbols.FilterToVisibleAndBrowsableSymbols(hideAdvancedMembers, semanticModel.Compilation);
return Task.FromResult(Tuple.Create<ImmutableArray<ISymbol>, SyntaxContext>(symbols, context));
}
示例5: IsTriggerCharacter
internal static bool IsTriggerCharacter(SourceText text, int characterPosition, OptionSet options)
{
var ch = text[characterPosition];
if (ch == '.')
{
return true;
}
// Trigger for directive
if (ch == '#')
{
return true;
}
// Trigger on pointer member access
if (ch == '>' && characterPosition >= 1 && text[characterPosition - 1] == '-')
{
return true;
}
// Trigger on alias name
if (ch == ':' && characterPosition >= 1 && text[characterPosition - 1] == ':')
{
return true;
}
if (options.GetOption(CompletionOptions.TriggerOnTypingLetters, LanguageNames.CSharp) && IsStartingNewWord(text, characterPosition))
{
return true;
}
return false;
}
示例6: IsTriggerAfterSpaceOrStartOfWordCharacter
internal static bool IsTriggerAfterSpaceOrStartOfWordCharacter(SourceText text, int characterPosition, OptionSet options)
{
// Bring up on space or at the start of a word.
var ch = text[characterPosition];
return SpaceTypedNotBeforeWord(ch, text, characterPosition) ||
(IsStartingNewWord(text, characterPosition) && options.GetOption(CompletionOptions.TriggerOnTypingLetters, LanguageNames.CSharp));
}
示例7: IsInsertionTrigger
internal override bool IsInsertionTrigger(SourceText text, int characterPosition, OptionSet options)
{
var ch = text[characterPosition];
return ch == ' ' ||
(CompletionUtilities.IsStartingNewWord(text, characterPosition) &&
options.GetOption(CompletionOptions.TriggerOnTypingLetters, LanguageNames.CSharp));
}
示例8: CheckBoxOptionViewModel
public CheckBoxOptionViewModel(IOption option, string description, string truePreview, string falsePreview, AbstractOptionPreviewViewModel info, OptionSet options)
{
this.Option = option;
Description = description;
_truePreview = truePreview;
_falsePreview = falsePreview;
_info = info;
SetProperty(ref _isChecked, (bool)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null)));
}
示例9: IsTriggerCharacter
public override bool IsTriggerCharacter(SourceText text, int characterPosition, OptionSet options)
{
if (!options.GetOption(CSharpCompletionOptions.IncludeSnippets))
{
return false;
}
return CompletionUtilities.IsTriggerCharacter(text, characterPosition, options);
}
示例10: MergeOptions
private OptionSet MergeOptions(OptionSet workspaceOptions, OptionSet userOptions)
{
var newOptions = workspaceOptions;
foreach (var key in userOptions.GetChangedOptions(workspaceOptions))
{
newOptions = newOptions.WithChangedOption(key, userOptions.GetOption(key));
}
return newOptions;
}
示例11: SendEnterThroughToEditorCore
protected override bool SendEnterThroughToEditorCore(CompletionItem completionItem, string textTypedSoFar, OptionSet options)
{
// If the text doesn't match, no reason to even check the options
if (completionItem.DisplayText != textTypedSoFar)
{
return false;
}
return options.GetOption(CSharpCompletionOptions.AddNewLineOnEnterAfterFullyTypedWord);
}
示例12: Log
public static void Log(OptionSet oldOptions, OptionSet newOptions)
{
foreach (var optionKey in newOptions.GetChangedOptions(oldOptions))
{
var oldValue = oldOptions.GetOption(optionKey);
var currentValue = newOptions.GetOption(optionKey);
Logger.Log(FunctionId.Run_Environment_Options, Create(optionKey, oldValue, currentValue));
}
}
示例13: CheckBoxWithComboOptionViewModel
public CheckBoxWithComboOptionViewModel(IOption option, string description, string truePreview, string falsePreview, AbstractOptionPreviewViewModel info, OptionSet options, IList<NotificationOptionViewModel> items)
: base(option, description, truePreview, falsePreview, info)
{
NotificationOptions = items;
var codeStyleOption = ((CodeStyleOption<bool>)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null)));
SetProperty(ref _isChecked, codeStyleOption.Value);
var notificationViewModel = items.Where(i => i.Notification.Value == codeStyleOption.Notification.Value).Single();
SetProperty(ref _selectedNotificationOption, notificationViewModel);
}
示例14: AddSuppressOperations
public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
{
nextOperation.Invoke(list);
AddBraceSuppressOperations(list, node);
AddStatementExceptBlockSuppressOperations(list, node);
AddSpecificNodesSuppressOperations(list, node);
if (!optionSet.GetOption(CSharpFormattingOptions.WrappingPreserveSingleLine))
{
RemoveSuppressOperationForBlock(list, node);
}
if (!optionSet.GetOption(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine))
{
RemoveSuppressOperationForStatementMethodDeclaration(list, node);
}
}
示例15: GetChangedOptions
internal override IEnumerable<OptionKey> GetChangedOptions(OptionSet optionSet)
{
foreach (var kvp in _values)
{
var currentValue = optionSet.GetOption(kvp.Key);
if (!object.Equals(currentValue, kvp.Value))
{
yield return kvp.Key;
}
}
}