public SqlCommandSet() { instance = Activator.CreateInstance(sqlCmdSetType, true); connectionSetter = (PropSetter <SqlConnection>) Delegate.CreateDelegate(typeof(PropSetter <SqlConnection>), instance, "set_Connection"); transactionSetter = (PropSetter <SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter <SqlTransaction>), instance, "set_Transaction"); commandTimeoutSetter = (PropSetter <int>) Delegate.CreateDelegate(typeof(PropSetter <int>), instance, "set_CommandTimeout"); connectionGetter = (PropGetter <SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter <SqlConnection>), instance, "get_Connection"); commandGetter = (SqlCommandSet.PropGetter <System.Data.SqlClient.SqlCommand>) Delegate.CreateDelegate(typeof(SqlCommandSet.PropGetter <System.Data.SqlClient.SqlCommand>), instance, "get_BatchCommand"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), instance, "Append"); doExecuteNonQuery = (ExecuteNonQueryCommand) Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteNonQuery"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); }
public void When_appending_item_on_cache_will_append_to_data_already_on_cache() { var buffer = new byte[] { 1, 2, 3, 4 }; ICommand command = new SetCommand(); command.SetContext(GetStreamWithData(buffer)); command.Init("foo", "1", "6000", "4"); command.FinishedExecuting += () => { wait.Set(); }; command.Execute(); wait.WaitOne(); wait.Reset(); buffer = new byte[] { 5, 6, 7, 8 }; MemoryStream stream = GetStreamWithData(buffer); command = new AppendCommand(); command.SetContext(stream); command.Init("foo", "1", "6000", "4"); command.FinishedExecuting += () => { wait.Set(); }; command.Execute(); wait.WaitOne(); CachedItem item = (CachedItem)Cache.Get("foo"); CollectionAssert.AreEqual(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, item.Buffer); }
public void When_appending_item_on_cache_will_reply_with_stored() { var buffer = new byte[] { 1, 2, 3, 4 }; ICommand command = new SetCommand(); command.SetContext(GetStreamWithData(buffer)); command.Init("foo", "1", "6000", "4"); command.FinishedExecuting += () => { wait.Set(); }; command.Execute(); wait.WaitOne(); wait.Reset(); buffer = new byte[] { 5, 6, 7, 8 }; MemoryStream stream = GetStreamWithData(buffer); command = new AppendCommand(); command.SetContext(stream); command.Init("foo", "1", "6000", "4"); command.FinishedExecuting += () => { wait.Set(); }; command.Execute(); wait.WaitOne(); Assert.AreEqual("STORED\r\n", ReadAll(6, stream)); }
public SqlClientSqlCommandSet() { instance = Activator.CreateInstance(sqlCmdSetType, true); connectionSetter = (PropSetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropSetter<SqlConnection>), instance, "set_Connection"); transactionSetter = (PropSetter<SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter<SqlTransaction>), instance, "set_Transaction"); commandTimeoutSetter = (PropSetter<int>) Delegate.CreateDelegate(typeof(PropSetter<int>), instance, "set_CommandTimeout"); connectionGetter = (PropGetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter<SqlConnection>), instance, "get_Connection"); commandGetter = (SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand>) Delegate.CreateDelegate(typeof(SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand>), instance, "get_BatchCommand"); doAppend = (AppendCommand) Delegate.CreateDelegate(typeof(AppendCommand), instance, "Append"); doExecuteNonQuery = (ExecuteNonQueryCommand) Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteNonQuery"); doDispose = (DisposeCommand) Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); }
public void When_appending_item_on_cache_will_not_modify_flags() { var buffer = new byte[] { 1, 2, 3, 4 }; ICommand command = new SetCommand(); command.SetContext(GetStreamWithData(buffer)); command.Init("foo", "1", "6000", "4"); command.FinishedExecuting += () => { wait.Set(); }; command.Execute(); wait.WaitOne(); wait.Reset(); buffer = new byte[] { 5, 6, 7, 8 }; MemoryStream stream = GetStreamWithData(buffer); command = new AppendCommand(); command.SetContext(stream); command.Init("foo", "15", "6000", "4"); command.FinishedExecuting += () => { wait.Set(); }; command.Execute(); wait.WaitOne(); CachedItem item = (CachedItem)Cache.Get("foo"); Assert.AreEqual(1, item.Flags); }
public override void ProcessAppendCommand(AppendCommand cmd) { this.Session.AppendResponse( new ServerStatusResponse(cmd.Tag, ServerStatusResponseType.NO, "APPEND is unsupportted yet") ); }
public async Task ReadResponse() { var command = new AppendCommand(); await StorageCommandValidator.AssertReadResponse(command, StorageCommandResult.Stored, true); await StorageCommandValidator.AssertReadResponse(command, StorageCommandResult.NotStored, false); await StorageCommandValidator.AssertReadResponseFailure<AppendCommand, bool>(command, StorageCommandResult.NotFound); await StorageCommandValidator.AssertReadResponseFailure<AppendCommand, bool>(command, StorageCommandResult.Exists); }
public virtual void ProcessAppendCommand(AppendCommand cmd) { this.Session.AppendResponse( new ServerStatusResponse(cmd.Tag, ServerStatusResponseType.NO, "APPEND State Error") ); }
public async Task AppendCommandHandler_MissingTask_ReturnsNull() { var command = new AppendCommand { ItemNumber = 12, Text = "Add" }; var result = await _handler.Handle(command, new CancellationToken()); result.Should().BeNull(); }
public async Task AppendCommandHandler_AppendedIsWrittenToFile() { var command = new AppendCommand { ItemNumber = 4, Text = "Add" }; _ = await _handler.Handle(command, new CancellationToken()); _taskFile.TaskLines[2].Should().EndWith("priority Add"); }
public async Task AppendCommandHandler_StripsWhitespace() { var command = new AppendCommand { ItemNumber = 4, Text = " Add " }; var result = await _handler.Handle(command, new CancellationToken()); result.Should().NotBeNull(); result.Description.Should().EndWith("priority Add"); }
public async Task AppendCommandHandler_RemovesBlankLinesFromTodoFile() { var command = new AppendCommand { ItemNumber = 2, Text = "Add" }; _ = await _handler.Handle(command, new CancellationToken()); _taskFile.TaskLines.Should().HaveCount(3); }
public MySqlClientSqlCommandSet(int batchSize) { instance = Activator.CreateInstance(sqlCmdSetType, true); doInitialise = (InitialiseCommand)Delegate.CreateDelegate(typeof(InitialiseCommand), instance, "InitializeBatching"); batchSizeSetter = (PropSetter<int>)Delegate.CreateDelegate(typeof(PropSetter<int>), instance, "set_UpdateBatchSize"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), instance, "AddToBatch"); doExecuteNonQuery = (ExecuteNonQueryCommand)Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteBatch"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); Initialise(batchSize); }
public MySqlClientSqlCommandSet(int batchSize) { instance = Activator.CreateInstance(sqlCmdSetType, true); doInitialise = (InitialiseCommand)Delegate.CreateDelegate(typeof(InitialiseCommand), instance, "InitializeBatching"); batchSizeSetter = (PropSetter <int>)Delegate.CreateDelegate(typeof(PropSetter <int>), instance, "set_UpdateBatchSize"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), instance, "AddToBatch"); doExecuteNonQuery = (ExecuteNonQueryCommand)Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteBatch"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); Initialise(batchSize); }
public async Task ReadResponse() { var command = new AppendCommand(); await StorageCommandValidator.AssertReadResponse(command, StorageCommandResult.Stored, true); await StorageCommandValidator.AssertReadResponse(command, StorageCommandResult.NotStored, false); await StorageCommandValidator.AssertReadResponseFailure <AppendCommand, bool>(command, StorageCommandResult.NotFound); await StorageCommandValidator.AssertReadResponseFailure <AppendCommand, bool>(command, StorageCommandResult.Exists); }
protected DbCommandSet() { object internalCommandSet = CreateInternalCommandSet(); commandGetter = (PropGetter <TCommand>) Delegate.CreateDelegate(typeof(PropGetter <TCommand>), internalCommandSet, "get_BatchCommand"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), internalCommandSet, "Append"); doExecuteNonQuery = (ExecuteNonQueryCommand) Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), internalCommandSet, "ExecuteNonQuery"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), internalCommandSet, "Dispose"); }
private async Task Append(int item, string text) { var command = new AppendCommand { ItemNumber = item, Text = text }; var result = await Mediator.Send(command); if (result is null) { Console.WriteLine($"TODO: No task {item}."); } else { Console.WriteLine(result.ToString(true)); } }
/// <summary> /// 생성자 /// </summary> public SqlCommandSet() { if (IsDebugEnabled) { log.Debug("{0}를 동적으로 생성하고, 내부 함수를 Delegate로 이용하여, 노출시킵니다.", SqlCommandSetTypeName); } _sqlCommandSetInstance = ActivatorTool.CreateInstance(_sqlCommandSetType, true); _sqlCommandSetInstance.ShouldNotBeNull(SqlCommandSetTypeName); _connectionSettter = (PropertySetter <SqlConnection>)CreateDelegate(typeof(PropertySetter <SqlConnection>), _sqlCommandSetInstance, "set_Connection"); _transactionSetter = (PropertySetter <SqlTransaction>)CreateDelegate(typeof(PropertySetter <SqlTransaction>), _sqlCommandSetInstance, "set_Transaction"); _commandTimeoutSetter = (PropertySetter <int>)CreateDelegate(typeof(PropertySetter <int>), _sqlCommandSetInstance, "set_CommandTimeout"); _connectionGetter = (PropertyGetter <SqlConnection>)CreateDelegate(typeof(PropertyGetter <SqlConnection>), _sqlCommandSetInstance, "get_Connection"); _batchCommandGetter = (PropertyGetter <SqlCommand>)CreateDelegate(typeof(PropertyGetter <SqlCommand>), _sqlCommandSetInstance, "get_BatchCommand"); _doAppend = (AppendCommand)CreateDelegate(typeof(AppendCommand), _sqlCommandSetInstance, "Append"); _doExecuteNonQuery = (ExecuteNonQueryCommand)CreateDelegate(typeof(ExecuteNonQueryCommand), _sqlCommandSetInstance, "ExecuteNonQuery"); _doDispose = (DisposeCommand)CreateDelegate(typeof(DisposeCommand), _sqlCommandSetInstance, "Dispose"); }
/// <summary> /// 생성자 /// </summary> public SqlCommandSet() { if(IsDebugEnabled) log.Debug("{0}를 동적으로 생성하고, 내부 함수를 Delegate로 이용하여, 노출시킵니다.", SqlCommandSetTypeName); _sqlCommandSetInstance = ActivatorTool.CreateInstance(_sqlCommandSetType, true); _sqlCommandSetInstance.ShouldNotBeNull(SqlCommandSetTypeName); _connectionSettter = (PropertySetter<SqlConnection>)CreateDelegate(typeof(PropertySetter<SqlConnection>), _sqlCommandSetInstance, "set_Connection"); _transactionSetter = (PropertySetter<SqlTransaction>)CreateDelegate(typeof(PropertySetter<SqlTransaction>), _sqlCommandSetInstance, "set_Transaction"); _commandTimeoutSetter = (PropertySetter<int>)CreateDelegate(typeof(PropertySetter<int>), _sqlCommandSetInstance, "set_CommandTimeout"); _connectionGetter = (PropertyGetter<SqlConnection>)CreateDelegate(typeof(PropertyGetter<SqlConnection>), _sqlCommandSetInstance, "get_Connection"); _batchCommandGetter = (PropertyGetter<SqlCommand>)CreateDelegate(typeof(PropertyGetter<SqlCommand>), _sqlCommandSetInstance, "get_BatchCommand"); _doAppend = (AppendCommand)CreateDelegate(typeof(AppendCommand), _sqlCommandSetInstance, "Append"); _doExecuteNonQuery = (ExecuteNonQueryCommand)CreateDelegate(typeof(ExecuteNonQueryCommand), _sqlCommandSetInstance, "ExecuteNonQuery"); _doDispose = (DisposeCommand)CreateDelegate(typeof(DisposeCommand), _sqlCommandSetInstance, "Dispose"); }
public Command ParseCommand(string commandInput) { var commandArguments = commandInput.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // first check if it's a valid command var length = commandArguments.Length; Command command = null; var action = commandArguments[0]; var parameters = commandArguments.Skip(1).ToList(); // make it with reflection, if you hate your life switch (action) { case "append": ValidateCommandLength(length, Constants.AppendCommandLength); command = new AppendCommand(parameters); break; case "prepend": ValidateCommandLength(length, Constants.PrependCommandLength); command = new PrependCommand(parameters); break; case "reverse": ValidateCommandLength(length, Constants.ReverseCommandLength); command = new ReverseCommand(parameters); break; case "insert": ValidateCommandLength(length, Constants.InsertCommandLength); command = new InsertCommand(parameters); break; case "delete": ValidateCommandLength(length, Constants.DeleteCommandLength); command = new DeleteCommand(parameters); break; case "roll": ValidateCommandLength(length, Constants.RollCommandLength); command = new RollCommand(parameters); break; case "sort": ValidateCommandLength(length, Constants.SortCommandLength); command = new SortCommand(parameters); break; case "count": ValidateCommandLength(length, Constants.CountCommandLength); command = new CountCommand(parameters); break; case "end": this.logger.Write(Constants.FinishedMessage); command = new EndCommand(parameters); break; default: throw new ArgumentException(Constants.InvalidCommand); } return(command); }
public AppendRequest(string emlContent, string flags, IFolder parentFolder, RequestCompletedCallback callback) : base(callback) { Command = new AppendCommand(emlContent, flags, parentFolder, null); ProcessorType = typeof(AppendProcessor); }