Skip to content

TitleCaseExtensions

A public module providing extension methods for string and string-array formatting operations. When SAIF.Business.Utilities is imported, these methods become available directly on String and String() objects in any consuming project — a wide ambient surface that adds casing, validation, and padding capabilities to the BCL string type. All members are public and shared; the module holds no state.

Purpose

  • Provide convenient extension-method façade over TitleCase.ToTitleCase for the title-casing operation commonly needed by display-layer code.
  • Support supplementary string-formatting operations: proper casing, capital-letter padding, numeric validation, array-level casing for use in word-list comparisons.

Context

  • Namespace: SAIF.Business.Utilities
  • Assembly/package: SAIF.Business.Utilities.dll
  • Module type: VB.NET Public Module (all members are extension methods decorated with <System.Runtime.CompilerServices.Extension()>)

Public members

Member Signature Purpose
ToTitleCase Public Function ToTitleCase(ByVal Target As String) As String Extension-method façade over TitleCase.ToTitleCase; the primary title-casing method used by callers. Accepts any string and returns the title-cased result using the rules-driven engine.
ToProperCase Public Function ToProperCase(ByVal Target As String) As String Apply VB StrConv(..., VbStrConv.ProperCase) for simple per-word capitalization; used as fallback in BR-009 when no recognition list matches.
ToPadCapitalLetters Public Function ToPadCapitalLetters(ByVal Target As String) As String Expand run-together identifiers (Pascal-cased text) into spaced words by inserting spaces before capital letters. Skipped if the value already contains a space (BR-018); otherwise delegates to SAIF.Framework.StandardFormats.PadCapitalLettersFormat.ApplyFormat.
ToLower Public Function ToLower(ByVal Target() As String) As String() Array-level lower-casing. Accepts a string array and returns a new array with each element lower-cased. Used internally for case-insensitive word-list comparison.
ToUpper Public Function ToUpper(ByVal Target() As String) As String() Array-level upper-casing. Accepts a string array and returns a new array with each element upper-cased. Used internally for case-insensitive word-list comparison.
ContainsOnlyNumericCharacters Public Function ContainsOnlyNumericCharacters(ByVal Target As String) As Boolean Guard for ordinal suffix detection. Confirms that a string is non-null, non-blank, and contains only digits (no \D match via regex Regex.IsMatch(..., "\\D")).

Behavioral notes

  • Ambient surface: Because TitleCaseExtensions is a Public Module, importing SAIF.Business.Utilities silently adds these extension methods to String and String() across any consuming project — a coupling characteristic that may be unexpected*.
  • Delegation to TitleCase.ToTitleCase: The ToTitleCase extension method simply forwards to the static TitleCase.ToTitleCase method; it does not duplicate logic.
  • StrConv behavior: The ToProperCase method uses the VB.NET runtime's StrConv(..., VbStrConv.ProperCase), which may behave differently across framework versions and locales. On .NET Framework 4.x it typically capitalizes the first letter of each space-delimited word*.
  • PadCapitalLettersFormat delegation: ToPadCapitalLetters delegates to SAIF.Framework.StandardFormats.PadCapitalLettersFormat (from SAIF.Framework.Common package). The exact implementation is not visible in this repository**.
  • Array methods: ToLower and ToUpper operate on string arrays and are used for case-insensitive recognition-list matching (e.g. comparing a token against UpperCaseWordList.ToUpper()). They return new arrays; the input array is not modified*.
  • Regex in ContainsOnlyNumericCharacters: Uses Regex.IsMatch(Target, "\\D") to check for non-digit characters; returns true only if no non-digit is found and the string is not null/blank.
  • Null/empty handling: Methods generally pass through null values unchanged or apply sensible defaults (e.g. ToLower/ToUpper return empty arrays if input is null); exact behavior per method should be verified from implementation*.

Constraints and usage notes

  • All members are stateless; calls are thread-safe.
  • The module's Public visibility means these extension methods are automatically injected into the namespace scope of any project importing SAIF.Business.Utilities, potentially creating unexpected method availability*.
  • The ToPadCapitalLetters method's behavior depends on the external PadCapitalLettersFormat type; changes to that type or its dependencies may affect output**.
  • Array-level methods (ToLower, ToUpper) allocate new arrays; no in-place modification occurs.
  • The regex pattern in ContainsOnlyNumericCharacters may not handle all Unicode digit representations (e.g. non-ASCII numeric characters) consistently depending on regex options*.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Business.Utilities/TitleCase.vb
  • SAIF.Business.Utilities/SAIF.Business.Utilities.vbproj