public void CadastrarFuncao(int potencia, TimeSpan tempo, string nome, string instrucao, char caractere, string alimento, bool SalvarAoInserir = true) { if (nome.Trim() == "") { if (!OnErro("O nome da função não informado")) { throw new NomeFuncaoNaoInformadaException("O nome da função não informado"); } } var funcao = new FuncaoMicroondas(potencia, tempo, nome, instrucao, caractere, alimento); funcao.Validar(); // garante que está dentro das restrições. Funcoes.Add(funcao); if (SalvarAoInserir) { SalvarFuncoesCadastradas(); } }
public async Task Iniciar(FuncaoMicroondas funcao, string entrada) { try { funcao.Validar(); funcao.ValidarEntrada(entrada.Trim()); FuncaoAtual = funcao; EntradaAquecida = entrada; TempoRestante = FuncaoAtual.Tempo; contadorSegundos = TimeSpan.Zero; await Ligar(entrada); } catch (Exception e) { if (!OnErro(e.Message)) { throw; } } }