public async Task <ActionResult <Subcommand> > PostSubcommand(Subcommand subcommand) { _context.Subcommands.Add(subcommand); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSubcommand", new { id = subcommand.Id_subcommand }, subcommand)); }
public async Task <IActionResult> PutSubcommand(int id, Subcommand subcommand) { if (id != subcommand.Id_subcommand) { return(BadRequest()); } _context.Entry(subcommand).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubcommandExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void ReturnᅠSuccessᅠvalidationᅠresponse(string projectName) { Subcommand.SetResolvedName(projectName); Validate().Should().NotBeNull().And.BeOfType <ValidationResult>(); Validate().IsValid.Should().BeTrue(); Validate().Message.Should().BeEmpty(); }
#pragma warning restore xUnit1019 // MemberData must reference a member providing a valid data type public void Returnᅠinvalidᅠvalidationᅠresponseᅠwithᅠerrorᅠmessage(string projectName, string errorMessage) { Subcommand.SetResolvedName(projectName); Validate().Should().NotBeNull().And.BeOfType <ValidationResult>(); Validate().IsValid.Should().BeFalse(); Validate().Message.Should().Be(errorMessage); }
public void CallCorrectClassWithGoodInputs(string[] parameters, Subcommand expectedSubcommand) { var restParams = parameters.Skip(1).ToArray(); Assert.IsTrue(ParameterResolver.DelegateToSubcommands(_factoryMock.Object, parameters).Success); var expectedCommandMock = expectedSubcommand == Subcommand.Sln ? _slnMock : _opcuaAppMock; expectedCommandMock.Verify(c => c.Execute(restParams), Times.Once); }
protected override Tuple <T1, T2>[] Read(long count, RedisReader reader) { var array = new Tuple <T1, T2> [count / 2]; for (int i = 0; i < count; i += 2) { array[i / 2] = Subcommand.Parse(reader); } return(array); }
//Separate method, you need to decide access modifier and parameters as per your requirement public DataFormatter Build() { Command cmd2 = new Command(Commands.CommandsEnum.Run); DataFormatter df2 = new DataFormatter(); df2._Command = cmd2; Subcommand scmd2 = new Subcommand(); scmd2.Action = Action; scmd2.ID = ID; scmd2.NewValueString = NewText; scmd2.Type = Type; df2._Subcommand = scmd2; return(df2); }
internal static byte[] ToBytes(this Subcommand subcommand) { var result = RedisConstants.RefCount; if (subcommand == Subcommand.IdleTime) { result = RedisConstants.IdleTime; } else if (subcommand == Subcommand.Encoding) { result = RedisConstants.ObjEncoding; } return(result); }
public static Report ReadSPI(int addr, byte size, IntPtr handle) { var sc = new Subcommand(SubcommandType.SPIFlashRead) .PackInt32(addr) .PackByte(size); var report = new Report(sc.Send(handle), DateTime.Now); report.Seek(15); if (report.ReadInt32() != addr || report.ReadByte() != size) { Debug.Log(string.Format("Invalid SPI report: {0}", Helper.ByteArrayToString(report.dataBuffer))); return(null); } return(report); }
public static void SetMCUMode(byte mode, IntPtr handle) { bool mcuReady = false; while (!mcuReady) { var result = new Subcommand(SubcommandType.SetNFCOrIRMCUConfiguration) .PackByte(0x21) .PackByte(0x00) .PackByte(mode).Send(handle); if (result[0] == 0x21) { if (result[15] == 0x01 && result[22] == 0x01) // MCU state is Standby { mcuReady = true; } } } }
public static void RequestMCUModeStatus(IntPtr handle) { bool mcuReady = false; while (!mcuReady) { var result = new Subcommand(SubcommandType.BluetoothManualPairing).Send(handle); if (result[0] == 0x31) { //if (result[49] == 0x01 && result[56] == 0x06) // MCU state is Initializing // *(u16*)result[52]LE x04 in lower than 3.89fw, x05 in 3.89 // *(u16*)result[54]LE x12 in lower than 3.89fw, x18 in 3.89 // result[56]: mcu mode state if (result[49] == 0x01 && result[56] == 0x01) // MCU state is Standby { mcuReady = true; } } } }
/// <summary> /// Todo: document this /// </summary> /// <param name="command"></param> /// <returns></returns> public DataFormatter Build(string command) { Enum.TryParse <Commands.CommandsEnum>(command, out enumResult); Command cmd2 = new Command(enumResult); DataFormatter df2 = new DataFormatter(); df2._Command = cmd2; Subcommand scmd2 = new Subcommand(); scmd2.Action = Action; scmd2.ID = ID; scmd2.NewValueString = NewText; scmd2.Type = Type; df2._Subcommand = scmd2; Action = ""; ID = ""; NewText = ""; Type = ""; return(df2); }
public Task<RedisResponse> ObjectAsync(Subcommand subcommand, params string[] args) { var request = ComposeRequest(RedisConstants.Object, subcommand.ToBytes(), args); return ExecuteRedisCommand(request); }
public Task <RedisResponse> ObjectAsync(Subcommand subcommand, params string[] args) { var request = ComposeRequest(RedisConstants.Object, subcommand.ToBytes(), args); return(ExecuteRedisCommand(request)); }