コード例 #1
0
        /// <summary>
        /// It loads the Bank info from the provided stream
        /// </summary>
        /// <param name="textIn">The stream to load the bank from</param>
        /// <returns>The DictionaryBank object</returns>
        public static DictionaryBank Load(TextReader textIn)
        {
            DictionaryBank result      = new DictionaryBank();
            string         countString = textIn.ReadLine();
            int            count       = int.Parse(countString);

            for (int i = 0; i < count; i++)
            {
                string   className = textIn.ReadLine();
                IAccount account   = AccountFactory.MakeAccount(className, textIn);
                result.accountDictionary.Add(account.GetName(), account);
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// It loads the Bank info from the provided file name
        /// </summary>
        /// <param name="filename">The file name that contains the Bank info</param>
        /// <returns>The DictionaryBank object</returns>
        public static DictionaryBank Load(string filename)
        {
            TextReader     textIn = null;
            DictionaryBank result = null;

            try
            {
                textIn = new StreamReader(filename);
                result = Load(textIn);
            }
            catch
            {
                return(null);
            }
            finally
            {
                if (textIn != null)
                {
                    textIn.Close();
                }
            }

            return(result);
        }