public static string StripHtmlElements(this string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(-1 == s.IndexOf('<') ? s : m_stripHtmlElements.Replace(s, string.Empty)); }
/// <summary> /// Performs a <see cref="StringComparison.OrdinalIgnoreCase"/> comparison between two <see cref="String.Trim()">trimmed</see> strings. /// </summary> /// <returns>True if trimmed strings match in an ordinal case insensive comparison, otherwise false.</returns> public static bool NormalEquals(this string s, string stringToCompare) { ArgumentValidator.ThrowIfNull(s, "s"); return(null != stringToCompare && s.Trim().Equals(stringToCompare.Trim(), StringComparison.OrdinalIgnoreCase)); }
public static string LowerFirstLetter(this string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(Char.ToLowerInvariant(s[0]) + s.Substring(1)); }
public static bool HasMagicRegexChars(string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(-1 != s.IndexOfAny(MagicRegexChars)); }
/// <summary> /// Formats a string and arguments using the <see cref="CultureInfo.InvariantCulture">invariant culture</see>. /// </summary> /// <remarks> /// <para>This should <b>not</b> be used for any strings that are displayed to the user. It is meant for log /// messages, exception messages, and other types of information that do not make it into the UI, or wouldn't /// make sense to users anyway ;).</para> /// </remarks> public static string FormatInvariant(this string format, params object[] args) { ArgumentValidator.ThrowIfNull(format, "format"); return(0 == args.Length ? format : string.Format(CultureInfo.InvariantCulture, format, args)); }
public static string SpacePascalOrCamel(this string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(m_pascalOrCamelRegex.Replace(s, "$1 ").ChopRight(1)); }
public static bool OicContains(this string s, string [] candidates) { ArgumentValidator.ThrowIfNull(s, "s"); ArgumentValidator.ThrowIfNull(candidates, "candidates"); return(candidates.Any(candidate => s.OicContains(candidate))); }
public static Type GetUnderlyingType(this Type t) { ArgumentValidator.ThrowIfNull(t, "t"); return(Nullable.GetUnderlyingType(t) ?? t); }
public static string EncodeHtml(this string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(HttpUtility.HtmlEncode(s)); }
public static string ToAbsolute(this string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(VirtualPathUtility.ToAbsolute(s)); }
public static string ToNullIfEmpty(string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(0 == s.Length ? null : s); }
/// <summary> /// Returns a trimmed, invariant upper case version of this <see cref="string" />. /// </summary> public static string Normalize(string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(s.Trim().ToUpperInvariant()); }
public static string FormatJson(this string format, params object[] args) { ArgumentValidator.ThrowIfNull(format, "format"); return(string.Format(JsonFormatter.Instance, format, args)); }
public static bool OicEquals(this string s1, string s2) { ArgumentValidator.ThrowIfNull(s1, "s1"); return(null != s2 && s1.Equals(s2, StringComparison.OrdinalIgnoreCase)); }
public static bool IsValidEmailAddress(this string s) { ArgumentValidator.ThrowIfNull(s, "s"); return(EmailPattern.IsMatch(s)); }
public static bool IsNumeric(Type t) { ArgumentValidator.ThrowIfNull(t, "t"); return(IsIntegralType(t) || IsFloatingPoint(t)); }
public static int OicLastIndexOf(this string s, string candidate) { ArgumentValidator.ThrowIfNull(s, "s"); ArgumentValidator.ThrowIfNull(candidate, "candidate"); return(s.LastIndexOf(candidate, StringComparison.OrdinalIgnoreCase)); }
public object GetAnnotation(string annotation) { ArgumentValidator.ThrowIfNullOrEmpty(annotation, "annotation"); return(this.GetAnnotation(this.TableChanges.GetAnnotationIdx(annotation))); }
/// <summary> /// Initializes a new instance of the <see cref="CognizantException" /> class with a specified error message. /// </summary> protected CognizantException(ExceptionInformation exceptionInformation, string message) : base(message) { ArgumentValidator.ThrowIfNull(exceptionInformation, "exceptionInformation"); m_exceptionInformation = exceptionInformation; }