public static ExecutedRoutedEventHandler CreateRoutedEditCommandHandler(CommandExecutionHandler handler, Func <SqlDocumentRepository> getDocumentRepositoryFunction) { return ((sender, args) => { var editor = GetEditorFromSender(sender); ExecuteEditCommand(getDocumentRepositoryFunction(), editor, handler.ExecutionHandler); }); }
public static ICollection<CommandExecutionHandler> ResolveCommandHandlers(OracleStatementSemanticModel semanticModel, StatementGrammarNode currentTerminal) { CheckParametersNotNull(semanticModel, currentTerminal); var commands = new List<CommandExecutionHandler>(); if (!CanConvertCurrentTerminal(currentTerminal)) { return EmptyHandlerCollection; } var requiredPrecedingTerminalId = GetRequiredPrecedingTerminalId(currentTerminal); var literalTerminals = FindUsagesCommand.GetEqualValueLiteralTerminals(semanticModel.Statement, currentTerminal) .Where(t => requiredPrecedingTerminalId == t.PrecedingTerminal.Id || (requiredPrecedingTerminalId == null && !t.PrecedingTerminal.Id.In(Terminals.Date, Terminals.Timestamp))) .ToArray(); var singleOccurenceConvertAction = new CommandExecutionHandler { Name = "Convert to bind variable", ExecutionHandler = c => new LiteralBindVariableConversionCommand(c, new[] { currentTerminal }, requiredPrecedingTerminalId) .Execute(), CanExecuteHandler = c => true }; commands.Add(singleOccurenceConvertAction); if (literalTerminals.Length > 1) { var allOccurencesConvertAction = new CommandExecutionHandler { Name = "Convert all occurences to bind variable", ExecutionHandler = c => new LiteralBindVariableConversionCommand(c, literalTerminals, requiredPrecedingTerminalId) .Execute(), CanExecuteHandler = c => true }; commands.Add(allOccurencesConvertAction); } return commands.AsReadOnly(); }
public static ICollection<CommandExecutionHandler> ResolveCommandHandlers(OracleStatementSemanticModel semanticModel, StatementGrammarNode currentTerminal) { CheckParametersNotNull(semanticModel, currentTerminal); if (!String.Equals(currentTerminal.Id, Terminals.BindVariableIdentifier)) return EmptyHandlerCollection; var bindVariable = FindUsagesCommand.GetBindVariable(semanticModel, currentTerminal.Token.Value); var singleOccurenceConvertAction = new CommandExecutionHandler { Name = "Convert to literal", ExecutionHandler = c => new BindVariableLiteralConversionCommand(c, bindVariable, false) .Execute(), CanExecuteHandler = c => true }; var commands = new List<CommandExecutionHandler> { singleOccurenceConvertAction }; if (bindVariable.Nodes.Count > 1) { var allOccurencesConvertAction = new CommandExecutionHandler { Name = "Convert all accurences to literal", ExecutionHandler = c => new BindVariableLiteralConversionCommand(c, bindVariable, true) .Execute(), CanExecuteHandler = c => true }; commands.Add(allOccurencesConvertAction); } return commands.AsReadOnly(); }
public OracleStatementFormatter() { ExecutionHandler = new CommandExecutionHandler { Name = "FormatStatement", DefaultGestures = GenericCommands.FormatStatement.InputGestures, ExecutionHandler = c => new StandardStatementFormatter(c).FormatStatements() }; SingleLineExecutionHandler = new CommandExecutionHandler { Name = "FormatStatementAsSingleLine", DefaultGestures = GenericCommands.FormatStatementAsSingleLine.InputGestures, ExecutionHandler = c => new SingleLineStatementFormatter(c).FormatStatements() }; NormalizeHandler = new CommandExecutionHandler { Name = "NormalizeStatement", DefaultGestures = GenericCommands.NormalizeStatement.InputGestures, ExecutionHandler = c => new StatementNormalizer(c).FormatStatements() }; }
public IEnumerable<ContextAction> GetSessionContextActions(DatabaseSession databaseSession) { var sessionValues = (OracleSessionValues)databaseSession.ProviderValues; var executionHandler = new CommandExecutionHandler(); string actionName; if (String.Equals(sessionValues.SqlTrace, "Disabled")) { actionName = "Enable trace"; executionHandler.ExecutionHandlerAsync = (context, cancellationToken) => EnableSessionTracing(sessionValues, sessionValues.TraceId, true, true, cancellationToken); } else { actionName = "Disable trace"; executionHandler.ExecutionHandlerAsync = (context, cancellationToken) => DisableSessionTracing(sessionValues, cancellationToken); } yield return new ContextAction(actionName, executionHandler, null, true); var remoteTraceDirectory = OracleConfiguration.Configuration.GetRemoteTraceDirectory(_connectionString.Name); var traceFileName = String.IsNullOrWhiteSpace(remoteTraceDirectory) ? sessionValues.TraceFile : Path.Combine(remoteTraceDirectory, new FileInfo(sessionValues.TraceFile).Name); executionHandler = new CommandExecutionHandler { ExecutionHandler = context => OracleTraceViewer.NavigateToTraceFile(traceFileName) }; yield return new ContextAction("Navigate to trace file", executionHandler, null); executionHandler = new CommandExecutionHandler { ExecutionHandlerAsync = (context, cancellationToken) => KillSession(sessionValues, cancellationToken) }; yield return new ContextAction("Kill", executionHandler, null, true); }