Beispiel #1
0
 public static void  Main0(System.String[] args)
 {
     try
     {
         Hashtable dat = new Hashtable();
         dat.Add("Quantity", (int)150);
         dat.Add("Volume", (double)20.5);
         ISelector sel = Selector.getInstance("Quantity > 100 AND Volume < 25");
         Result    res = sel.eval(dat);
         System.Console.WriteLine(res.ToString());
     }
     catch (System.Exception ex)
     {
         SupportClass.WriteStackTrace(ex, Console.Error);
     }
 }
Beispiel #2
0
        private static void DoTest1()
        {
            try
            {
                Hashtable dat = new Hashtable();
                dat.Add("Quantity", (int)150);
                dat.Add("Volume", (double)20);
                dat.Add("Price", (double)1234.56);
                dat.Add("Coupon", (decimal)6.5);
                dat.Add("CUSIP", "123456789");

                string    selStr = "CUSIP LIKE '1234%' AND Coupon > 6.5 AND Quantity > 100 AND (Volume < 10 OR Price > 1000)";
                ISelector sel    = Selector.getInstance(selStr);

                DateTime start   = System.DateTime.Now;
                int      maxIter = 2000000;
                for (int i = 0; i < maxIter; ++i)
                {
                    Result res = sel.eval(dat);
                    if (res == Result.RESULT_TRUE)
                    {
                        // Success
                    }
                    else if (res == Result.RESULT_FALSE)
                    {
                        // Failure
                    }
                    else
                    {
                        // Unknown
                    }
                }
                DateTime end  = System.DateTime.Now;
                TimeSpan diff = end.Subtract(start);
                System.Console.WriteLine("Selector: " + selStr);
                System.Console.WriteLine(maxIter + " evaluations in: " + diff.ToString());
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.StackTrace);
            }
        }
Beispiel #3
0
        private static void DoTest2()
        {
            try
            {
                Hashtable dat = new Hashtable();
                dat.Add("TICKER", "MSFT");

                string    selStr = "TICKER IN ('TIBX', 'MSFT', 'IBM')";
                ISelector sel    = Selector.getInstance(selStr);

                DateTime start   = System.DateTime.Now;
                int      maxIter = 2000000;
                for (int i = 0; i < maxIter; ++i)
                {
                    Result res = sel.eval(dat);
                    if (res == Result.RESULT_TRUE)
                    {
                        // Success
                    }
                    else if (res == Result.RESULT_FALSE)
                    {
                        // Failure
                    }
                    else
                    {
                        // Unknown
                    }
                }
                DateTime end  = System.DateTime.Now;
                TimeSpan diff = end.Subtract(start);
                System.Console.WriteLine("Selector: " + selStr);
                System.Console.WriteLine(maxIter + " evaluations in: " + diff.ToString());
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.StackTrace);
            }
        }