// Get information on file containing serialized dictionary
        object[] ICalculator.ReportOnDictionary(string FileFullName, bool OnOff)
        {
            object[] output = new object[3];
            if (OnOff)
            {
                if (File.Exists(FileFullName))
                {
                    try
                    {
                        BondDictionary SD = new BondDictionary(@FileFullName);
                        SD.DeSerialize();

                        // blank dictionary
                        if (SD.dic.Count == 0)
                        {
                            output[0] = (string)"Empty Dictionary";
                        }
                        else
                        {
                            output[0] = (int)SD.dic.Count;

                            FileInfo fi = new FileInfo(@FileFullName);
                            output[1] = fi.LastWriteTime.ToString();

                            double?date = null;

                            foreach (KeyValuePair <string, BaseBond> b in SD.dic)
                            {
                                if (date == null)
                                {
                                    date = b.Value.GetToday().SerialValue;
                                }
                                if (date == b.Value.GetToday().SerialValue)
                                {
                                    date = b.Value.GetToday().SerialValue;
                                }
                                else
                                {
                                    output[2] = (string)"Not equal refDates";
                                }
                                output[2] = date;
                            }
                        }
                    }
                    catch (Exception e)    // exception
                    {
                        output[0] = (string)e.ToString();
                    }
                }
                else
                {
                    output[0] = (string)"File not found";
                }
                return(output);
            }
            else
            {
                return(output);
            }
        }
 // Update serialized dictionary
 string ICalculator.UpdateSerializedDictionary(string FileFullPath)
 {
     try
     {
         BondDictionary SD = new BondDictionary(@FileFullPath);
         SD.DeSerialize();
         foreach (KeyValuePair <string, BaseBond> k in BondDictionarySerial)
         {
             string   idCode = k.Key;
             BaseBond bond   = k.Value;
             if (SD.dic.ContainsKey(idCode) == true) // check if idCode is in dictionary
             {
                 SD.dic[idCode] = bond;              // if true, updates it
             }
             else
             {
                 SD.dic.Add(idCode, bond); // if false, adds it
             }
         }
         SD.Serialize();                                               // serialize it
         BondDictionarySerial.Clear();
         return("Dictionary Serialized @ " + DateTime.Now.ToString()); // return time of last load
     }
     catch (Exception e)
     {
         return((string)e.ToString());
     }
 }
        // given a clean price and idCode will return the yield of the corresponding bond in BondDictionaryData
        object ICalculator.CleanFromYieldFromFile(string idCode, double Today, double Yield, int Freq, string DayCount, string Compounding, string FileFullName)
        {
            // int Freq, string DayCount, string Compounding refers to yield calculation
            // string idCode is the identification code of bond in BondDictionaryData

            // make it volatile
            if (m_xlApp != null)
            {
                m_xlApp.Volatile(true);
            }
            try
            {
                BaseBond bond = null; // initialise a bond
                // deserialize
                BondDictionary SD = new BondDictionary(@FileFullName);
                SD.DeSerialize();

                if (SD.dic.TryGetValue(idCode, out bond)) // is the idCode in dictionary?
                {
                    // update today since I the bond in dictionary can be the same but I can change my reference date to do simulations
                    bond.SetNewToDay(new Date(Today));

                    // Parse enum Type
                    Dc          dc   = (Dc)Enum.Parse(typeof(Dc), DayCount);
                    Compounding comp = (Compounding)Enum.Parse(typeof(Compounding), Compounding);

                    // if  yield is zero return a message
                    if (Yield == 0)
                    {
                        return((string)"YldZero");
                    }

                    // return clean price from yield given parameters
                    return(bond.CleanPriceFromYield(Yield, Freq, dc, comp));
                }
                else
                {
                    return("IdCode not found"); // bond not found
                }
            }
            catch (Exception e)
            {
                return((string)e.ToString());
            }
        }
        // Look up a bond code in the dictionary
        string ICalculator.CheckCode(string idCode, string FileFullName, bool OnOff)
        {
            if (OnOff)
            {
                try
                {
                    BondDictionary BD = new BondDictionary(FileFullName);

                    BD.DeSerialize();
                    return(BD.dic.ContainsKey(idCode).ToString()); // check for idCode
                }
                catch (Exception e)                                // exception
                {
                    return((string)e.ToString());
                }
            }
            else
            {
                return("");
            }
        }
 // Update Today for each bond in the dictionary
 string ICalculator.UpdateToday(double NewToday, string FileFullName, bool OnOff)
 {
     if (OnOff)
     {
         try
         {
             BondDictionary BD = new BondDictionary(FileFullName);
             BD.DeSerialize();
             BD.SetRefDate(new Date(NewToday));
             BD.Serialize();
             return("Updated @ " + DateTime.Now.ToString()); // return time of last load
         }
         catch (Exception e)                                 // exception
         {
             return((string)e.ToString());
         }
     }
     else
     {
         return("");
     }
 }