Exemple #1
0
        static void Main(string[] args)
        {
            "Testing DBFactory Package".title('=');
            WriteLine();
            DBFactoryTest dbft = new DBFactoryTest();

            "\nCreation of immutable database".title();
            WriteLine();

            "\nOriginal database".title();
            DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >();

            dbft.insertData(db);


            "\n Fetch all the keys which are even from the above database".title();
            try
            {
                QueryEngine <int, DBElement <int, string> > qEngine     = new QueryEngine <int, DBElement <int, string> >(db);
                Dictionary <int, DBElement <int, string> >  dictFactory = new Dictionary <int, DBElement <int, string> >();
                DBFactory <int, DBElement <int, string> >   dbFactory;
                var keys = qEngine.getListKeyPattern();
                if (keys != null)
                {
                    foreach (var key in keys)
                    {
                        var val = db.getValueOfKey(key);
                        dictFactory.Add(key, val);                                                              //add keys and values to the dictionary
                    }
                    dbFactory = new DBFactory <int, DBElement <int, string> >(dictFactory);                     //store the dictionary in the
                    WriteLine("\nThe below key/value pairs with even keys pattern are saved as an immutable database\n");
                    dbFactory.showDB();                                                                         //display the immutable database
                    WriteLine();
                    WriteLine();
                }
                else
                {
                    WriteLine("\nNo keys are obtained from a query for creation of immutable database\n");
                }
                WriteLine();
                WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("\n" + e.Message + "\n");
            }
        }
        static void Main(string[] args)
        {
            "Testing DBFactory Package".title('=');
            WriteLine();
            DBFactoryTest dbft = new DBFactoryTest();
            "\nCreation of immutable database".title();
            WriteLine();

            "\nOriginal database".title();
            DBEngine<int, DBElement<int, string>> db = new DBEngine<int, DBElement<int, string>>();
            dbft.insertData(db);
            

            "\n Fetch all the keys which are even from the above database".title();
            try
            {
                QueryEngine<int, DBElement<int, string>> qEngine = new QueryEngine<int, DBElement<int, string>>(db);
                Dictionary<int, DBElement<int, string>> dictFactory = new Dictionary<int, DBElement<int, string>>();
                DBFactory<int, DBElement<int, string>> dbFactory;
                var keys = qEngine.getListKeyPattern();
                if (keys != null)
                {
                    foreach (var key in keys)
                    {
                        var val = db.getValueOfKey(key);
                        dictFactory.Add(key, val);                                                              //add keys and values to the dictionary
                    }
                    dbFactory = new DBFactory<int, DBElement<int, string>>(dictFactory);                        //store the dictionary in the 
                    WriteLine("\nThe below key/value pairs with even keys pattern are saved as an immutable database\n");
                    dbFactory.showDB();                                                                         //display the immutable database
                    WriteLine();
                    WriteLine();
                }
                else
                {
                    WriteLine("\nNo keys are obtained from a query for creation of immutable database\n");
                }
                WriteLine();
                WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("\n" + e.Message + "\n");
            }

        }