SILUBS.ScriptureChecks.CapitalizationCheck.GetErrorMessage C# (CSharp) Method

GetErrorMessage() static private method

Gets the error message given the style's reason for capitalization.
static private GetErrorMessage ( IChecksDataSource dataSource, StyleCapInfo capReasonType, string styleName ) : string
dataSource IChecksDataSource The data source.
capReasonType StyleCapInfo Reason why a character should have been capitalized.
styleName string Name of the style or string.Empty if not relevant.
return string
		internal static string GetErrorMessage(IChecksDataSource dataSource,
			StyleCapInfo.CapCheckTypes capReasonType, string styleName)
		{
			switch (capReasonType)
			{
				case StyleCapInfo.CapCheckTypes.SentenceInitial:
					return dataSource.GetLocalizedString("Sentence should begin with a capital letter");
				case StyleCapInfo.CapCheckTypes.Heading:
					return dataSource.GetLocalizedString("Heading should begin with a capital letter");
				case StyleCapInfo.CapCheckTypes.Title:
					return dataSource.GetLocalizedString("Title should begin with a capital letter");
				case StyleCapInfo.CapCheckTypes.List:
					return dataSource.GetLocalizedString("List paragraphs should begin with a capital letter");
				case StyleCapInfo.CapCheckTypes.Table:
					return dataSource.GetLocalizedString("Table contents should begin with a capital letter");
				case StyleCapInfo.CapCheckTypes.ProperNoun:
					return dataSource.GetLocalizedString("Proper nouns should begin with a capital letter");
				case StyleCapInfo.CapCheckTypes.Special:
					return String.Format(dataSource.GetLocalizedString(
						"Text in the {0} style should begin with a capital letter"), styleName);
			}

			throw new Exception("Reason for capitalizing the style " + styleName +
				" is not handled in GetErrorMessage (" + capReasonType.ToString() + ")");
		}
	}

Usage Example

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a checking error if paragraph style requires an initial uppercase letter,
        /// but the tssFirstLetter is lowercase.
        /// </summary>
        /// <param name="tok">The Scripture token.</param>
        /// <param name="ttsFirstLetter">The token substring of the first word-forming character
        /// in the given token.</param>
        /// <param name="result">The error results.</param>
        /// <returns><c>true</c> if an error was added to the list of results; otherwise
        /// <c>false</c></returns>
        /// ------------------------------------------------------------------------------------
        private bool CheckForParaCapitalizationError(ITextToken tok,
                                                     TextTokenSubstring ttsFirstLetter, List <TextTokenSubstring> result)
        {
            if (m_foundParagraphText)
            {
                return(false);
            }

            m_foundParagraphText = true;

            // The first character of the paragraph is lowercase.
            // Look it up in the capitalized styles dictionary to determine if it should be uppercase.
            StyleCapInfo styleCapInfo;

            if (m_allCapitalizedStyles.TryGetValue(m_paragraphStyle, out styleCapInfo))
            {
                ttsFirstLetter.InventoryText = m_paragraphStyle;

                ttsFirstLetter.Message = CapitalizationCheck.GetErrorMessage(m_checksDataSource,
                                                                             styleCapInfo.m_capCheck, m_paragraphStyle);
                result.Add(ttsFirstLetter);
                return(true);
            }
            return(false);
        }
All Usage Examples Of SILUBS.ScriptureChecks.CapitalizationCheck::GetErrorMessage