Ejemplo n.º 1
0
        public App()
        {
            if (db.GetCurrency(Utils.currencyCodes[0]) == null) // db not initialized
            {
                // initialize db with default rate (-1) // changed to 1. -1 was giving problems.
                foreach (string cod in Utils.currencyCodes)
                {
                    db.UpdateCurrency(new Currency()
                    {
                        code = cod, rate = 1.0
                    });
                }

                db.SetGlobal("favouriteCurrency", "EUR");
            }

            foreach (WalletAmount wa in db.GetWalletAmounts())
            {
                wallet.AddAmount(wa.code, wa.amount);
            }


            // The root page of your application
            var content = new InputValuePage(db, wallet);

            MainPage = new NavigationPage(content);

            content.UpdateCurrencies();
        }
Ejemplo n.º 2
0
 public static void RefreshRates(DatabaseOps db, InputValuePage page)
 {
     foreach (string code in Utils.currencyCodes)
     {
         var uri = string.Format("http://download.finance.yahoo.com/d/quotes?f=sl1d1t1&s={0}{1}=X", "EUR", code);
         var cb  = new AsyncCallback(CallHandler);
         CallWebAsync(uri, db, cb, page);
     }
 }
Ejemplo n.º 3
0
        private static void CallWebAsync(string uri, DatabaseOps db, AsyncCallback cb, InputValuePage page)
        {
            var request = HttpWebRequest.Create(uri);

            request.Method = "GET";
            var state = new Tuple <DatabaseOps, WebRequest, InputValuePage>(db, request, page);

            request.BeginGetResponse(cb, state);
        }