Exemplo n.º 1
0
        private void SolicitacaoSQL()
        {
            RPN rpn = new RPN();

            string commandText = txtSql.Text;

            char[] infix_   = commandText.ToCharArray();
            char[] infix_u_ = commandText.ToUpper().ToCharArray();

            int iteracoes = Convert.ToInt32(txtIteracoes.Text);

            int    tick   = Environment.TickCount;
            object result = null;

            unsafe
            {
                fixed(char *infix = infix_)
                fixed(char *infix_u = infix_u_)
                {
                    Queue <char[]> strings;

                    char[]         pos_fixa  = null;
                    RPN.variavel[] variaveis = null;

                    for (int i = 0; i < iteracoes; i++)
                    {
                        pos_fixa = rpn.InfixaParaPosfixa(infix_, infix_u_, out strings);
                        result   = rpn.Avaliar(pos_fixa, strings, variaveis, out variaveis);
                    }

                    txtPosFixa.Text = new string(pos_fixa);
                }
            }
            int tempoGasto = Environment.TickCount - tick;

            this.Text = tempoGasto.ToString() + "ms";

            txtResultado.Text = Convert.ToString(result);
        }