示例#1
0
        /// <summary>
        /// Writes the Book Title to Authors file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="title">The Title to write.</param>
        /// <returns></returns>
        public bool WriteBookTitleToAuthorsFile(string filePath, string title)
        {
            if (!_validate.ValidateStringIsNotNull(title))
            {
                return(false);
            }
            if (!_validate.ValidateStringHasLength(title))
            {
                return(false);
            }
            if (!_validate.ValidateStringIsNotNull(filePath))
            {
                return(false);
            }
            if (!_validate.ValidateStringHasLength(filePath))
            {
                return(false);
            }
            if (!_validate.ValidateFileExists(filePath, true))
            {
                return(false);
            }

            using (var writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine(title);
            }

            return(true);
        }
        /// <summary>
        ///     The GetPathToSpecialDirectoryAppDataLocal.
        /// </summary>
        /// <returns>
        ///     The <see cref="string" /> .
        /// </returns>
        // ReSharper disable once MemberCanBeMade.Global
        public bool GetPathToSpecialDirectoryAppDataLocal()
        {
            var validate = new ValidationClass();
            var dirPath  = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            if (!validate.ValidateStringIsNotNull(dirPath))
            {
                return(false);
            }

            BookListPathsProperties.PathAppDataDirectory = dirPath;

            return(true);
        }
示例#3
0
        /// <summary>
        ///     add a dash to authors name so first middle and last name can be identified
        ///     by the program.
        /// </summary>
        /// <param name="author">The Author<see cref="string" />.</param>
        /// <returns>The <see cref="string" />.</returns>
        private string AddDashToAuthorName(string author)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var validate = new ValidationClass();

            if (!validate.ValidateStringIsNotNull(author))
            {
                return(string.Empty);
            }
            if (!validate.ValidateStringHasLength(author))
            {
                return(string.Empty);
            }

            var authorName = string.Empty;

            foreach (var letter in author)
            {
                authorName = string.Concat(authorName, char.IsWhiteSpace(letter) ? "-" : letter.ToString());
            }

            return(authorName);
        }