Example #1
0
        public static void preRequest(DateTime from, DateTime to, string abb)
        {
            /*
             * Generate List of names and abbreviations
             */
            CurrencyNameList.Generate();
            foreach (CurrencyName name in CurrencyNameList.Get())
            {
                //Console.WriteLine(name.abbreviation + " is " + name.name);
            }

            /*
             * Generate Range
             */
            Range range = new Range(from, to);

            /*
             * Generate Currency List
             */
            Currency currency = new Currency(abb, range);

            Console.WriteLine(currency.Name + " (" + currency.Abbreviation + ")");

            for (int i = 0; i < currency.GetDatesCount(); i++)
            {
                Console.Write("i: " + (i + 1) + "   ");
                Console.Write(currency.GetDateByIndex(i).Date + "  ");
                Console.Write(currency.GetRateByIndex(i));
                Console.WriteLine();
            }
        }
Example #2
0
        private List <DateTime> dates;   // list of dates



        /// <summary>
        /// Inputs: Range, abbreviation of vurrency and other auxiliary data
        /// Outputs: Lists of dates (X axis) and rate values (Y axis)
        /// </summary>
        /// <param name="a">three letter Aabbreviation</param>
        /// <param name="r">range of data</param>
        public Currency(string a, Range r)
        {
            /// Get name of the currency
            CurrencyNameList.Generate();           // create list of names and abbreviation
            var nameList = CurrencyNameList.Get(); // save list to variable
            // Loop through list of names and currencies
            int j = 0;                             // index

            foreach (CurrencyName currencyName in nameList)
            {
                j++;    // increment index, in the beginning, because we refer to first position as 1, and to the last one as equal to nameList.Count
                // if passed abbreviation and the abbreviation from the list are matching, save name to field and break the Loop
                if (currencyName.abbreviation == a)
                {
                    name = currencyName.name;   // save name to field
                    break;                      // break the loop
                }
                // if last currency in list has been checkd and it doesn't match with passed abbreviation - it means that passed abbreviation doesn't match with any in the list and name should be set to a dummy value
                if (j == nameList.Count)
                {
                    name = "000_dummy_000";
                }
            }

            // save constructor inputs to fields
            abbreviation = a;
            //range = r;
            toDate   = r.AdjustedTo;
            fromDate = r.AdjustedFrom;



            // create and return Lists of dates and rates
            (rates, dates) = CreateEntries(abbreviation, r);
        }
Example #3
0
        private static Currency OneCurrency(DateTime from, DateTime to, string abb)
        {
            /*
             * Generate List of names and abbreviations
             */
            CurrencyNameList.Generate();

            /*
             * Generate Range
             */
            Range range = new Range(from, to);

            /*
             * Generate Currency List
             */
            Currency currency = new Currency(abb, range);

            return(currency);
        }