Пример #1
0
        /// ********************************************************************************
        /// <summary>
        /// Validate real spelling list by reading header from file should be Art2MmSpell!!
        /// </summary>
        /// <param name="filePath">The path to the file.</param>
        /// <returns>True if valid spelling list else false.</returns>
        /// <created>art2m,5/12/2019</created>
        /// <changed>art2m,5/23/2019</changed>
        /// ********************************************************************************
        public static bool ReadHeader(string filePath)
        {
            try
            {
                using (var fileRead = new StreamReader(filePath))
                {
                    var word = fileRead.ReadLine();

                    return(ValidationClass.ValidateThisIsArt2MSpellSpellingList(word));
                }
            }
            catch (ArgumentNullException ex)
            {
                MyMessagesClass.ErrorMessage = "The file path value is a null string. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
                return(false);
            }
            catch (ArgumentException ex)
            {
                MyMessagesClass.ErrorMessage = "The file path value is an empty string.";

                Debug.WriteLine(ex.ToString());
                MyMessagesClass.ShowErrorMessageBox();

                return(false);
            }
            catch (FileNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = "Unable to locate this file. " + filePath;

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();
                return(false);
            }
            catch (DirectoryNotFoundException ex)
            {
                MyMessagesClass.ErrorMessage = "Unable to locate the directory.";

                Debug.WriteLine(ex.ToString());
                MyMessagesClass.ShowErrorMessageBox();

                return(false);
            }
            catch (IOException ex)
            {
                MyMessagesClass.ErrorMessage = "File path has invalid characters in it.";

                Debug.WriteLine(ex.ToString());

                MyMessagesClass.ShowErrorMessageBox();

                return(false);
            }
        }
Пример #2
0
        /// ********************************************************************************
        /// <summary>
        /// Validate word then if valid place into the collection.
        /// </summary>
        /// <param name="word"></param>
        /// <created>art2m,5/21/2019</created>
        /// <changed>art2m,5/23/2019</changed>
        /// ********************************************************************************
        private static void ValidateWordFromSpellingListAddToCollection(string word)
        {
            // check for valid spell list by checking words are all letters and not empty.
            if (!ValidationClass.ValidateSpellingWord(word))
            {
                return;
            }

            Swc.AddItem(word);
        }