public ProjectCompositeCommandAdapter( ProjectCommandController projectCommandController, CompositeCommand <OperationContext> composite, OperationContext operationContext) : base(true, false) { // Save the operation context so we can call back into the editor. this.operationContext = operationContext; // Go through the commands and wrap each one. foreach (ICommand <OperationContext> command in composite.Commands) { IWrappedCommand wrappedCommand = projectCommandController.WrapCommand(command, operationContext); Commands.Add(wrappedCommand); } }
public void Do( ICommand <OperationContext> command, OperationContext context) { // Every command needs a full write lock on the blocks. using (Project.Blocks.AcquireLock(RequestLock.Write)) { // Create the context for the block commands. var blockContext = new BlockCommandContext(Project); LinePosition linePosition = context.Position.LinePosition; int lineIndex = linePosition.GetLineIndex(Project.Blocks.Count); Block currentBlock = Project.Blocks[lineIndex]; blockContext.Position = new BlockPosition( currentBlock, context.Position.CharacterPosition); // Wrap the command with our wrappers. IWrappedCommand wrappedCommand = WrapCommand(command, context); Project.Commands.Do(wrappedCommand, blockContext); // Set the operation context from the block context. if (blockContext.Position.HasValue) { // Grab the block position and figure out the index. BlockPosition blockPosition = blockContext.Position.Value; int blockIndex = Project.Blocks.IndexOf(blockPosition.BlockKey); var position = new TextPosition(blockIndex, (int)blockPosition.TextIndex); // Set the context results. context.Results = new LineBufferOperationResults(position); } // Make sure we process our wrapped command. wrappedCommand.PostDo(context); } }
public static Task WriteToServerAsync(this IWrappedCommand cmd, DbContext context, string destinationTable, params string[] fields) { return(cmd.UseReaderAsync(x => x.WriteToServerAsync(context, destinationTable, fields))); }
public static void WriteToServer(this IWrappedCommand cmd, DbContext context, string destinationTable, params string[] fields) { cmd.UseReader(x => x.WriteToServer(context, destinationTable, fields)); }
public static Task WriteToServerAsync(this IWrappedCommand cmd, DbContext context, string destinationTable, BulkOptions bulkOptions, CancellationToken cancellationToken, params string[] fields) { return(cmd.UseReaderAsync(x => x.WriteToServerAsync(context, destinationTable, bulkOptions, cancellationToken, fields))); }
public static Task UseReaderAsync(this IWrappedCommand cmd, Func <DbDataReader, Task> action) { return(cmd.UseReaderAsync(CancellationToken.None, action)); }