Exemplo n.º 1
0
        public ActionResult Index(DadosEntrada model)
        {
            if (ModelState.IsValid)
            {
                IFuncao f;
                #region Leitura da função
                if (!string.IsNullOrWhiteSpace(model.F))
                {
                    f = new FuncaoTexto(model.F);
                    #region "Validação" da função
                    try
                    {
                        //Gambiarra pra testar se a função é válida
                        string obj = f.Em(model.A).ToString();
                        obj = f.Em(model.X0).ToString();
                    }
                    catch (Exception)
                    {
                        ModelState.AddModelError("F", "Função inválida.");
                    }
                    #endregion
                }
                else
                {
                    f = new FuncaoDelegate(x => Pow(x, 2) + 2 * x);
                }
                #endregion

                if (ModelState.IsValid)
                {
                    var res = Avalia(model, f);
                    return(View("Result", res));
                }
            }

            return(View(model));
        }
Exemplo n.º 2
0
 private void button3_Click(object sender, EventArgs e)
 {
     aFuncao -= FuncaoDaClasse;
 }
Exemplo n.º 3
0
 private void button2_Click(object sender, EventArgs e)
 {
     //fiz a ligação do delegate com a função escrita
     aFuncao = FuncaoDaClasse;
 }