Beispiel #1
0
        public void CarregarFuncoesCadastradas()
        {
            var FS = ServiceLocator.Get <IFileService>();

            try
            {
                Funcoes.Clear();
                foreach (var item in FuncoesPredefinidas())
                {
                    Funcoes.Add(item);
                }

                if (FS != null)
                {
                    var json = FS.Carregar(FS.GetExePath("funcoes.json"));
                    var list = JsonConvert.DeserializeObject <List <FuncaoMicroondas> >(json);
                    foreach (var item in list)
                    {
                        Funcoes.Add(item);
                    }
                }
            }
            catch (FileNotFoundException)
            {
                //Não fazer nada caso o Arquivo não exista
            }
            catch (Exception e)
            {
                if (!OnErro(e.Message))
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        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();
            }
        }