public override object GetOptions(CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(null); } var service = document.Project.LanguageServices.GetService <IRefactoringOptionsService>(); var model = new ExtractConverterModel(); var semantics = this.document.GetSemanticModelAsync(this.token).Result; var symbol = semantics.GetDeclaredSymbol(this.declaration); var symbolText = symbol.Name.EndsWith("dto", StringComparison.OrdinalIgnoreCase) ? symbol.Name.Substring(0, symbol.Name.Length - 3) : symbol.Name; bool isInterface = this.declaration.IsKind(SyntaxKind.InterfaceDeclaration); if (this.declaration.Identifier.Text.EndsWith("dto", StringComparison.OrdinalIgnoreCase) && isInterface == false) { model.EnableDtoSelect = false; model.EnableModelSelect = true; model.SelectedDto = symbol; model.PossibleModels = this.LookupPossibleTypes( symbol, x => x.Name.ToUpper().Contains(symbolText.ToUpper()) && x.Name.EndsWith("dto", StringComparison.OrdinalIgnoreCase) == false && x.Name.EndsWith("provider", StringComparison.OrdinalIgnoreCase) == false && x.Name.EndsWith("service", StringComparison.OrdinalIgnoreCase) == false && x.Name.EndsWith("converter", StringComparison.OrdinalIgnoreCase) == false && x.Name.EndsWith("controller", StringComparison.OrdinalIgnoreCase) == false && x.Name.EndsWith("builder", StringComparison.OrdinalIgnoreCase) == false) .OrderByDescending(x => x.Name.EndsWith("Model")).ThenByDescending(x => x.Name.StartsWith("I")); model.SelectedModel = model.PossibleModels.FirstOrDefault(); } else { model.EnableDtoSelect = true; model.EnableModelSelect = false; model.PossibleDtos = this.LookupPossibleTypes( symbol, x => x.Name.ToUpper().Contains(symbolText.ToUpper()) && x.Name.EndsWith("dto", StringComparison.OrdinalIgnoreCase)); model.SelectedModel = symbol; model.SelectedDto = model.PossibleDtos.FirstOrDefault(); } if (isInterface) { model.ImplementDtoConvertDisabled = true; model.ImplementDtoConvert = false; } var result = service.GetOptions(model); if (result) { return(model); } return(null); }
private Task <Solution> ImplementConverterAsync(CancellationToken cancellationToken, ExtractConverterModel model) { throw new NotImplementedException(); }