예제 #1
0
        public static string StripHtmlElements(this string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(-1 == s.IndexOf('<') ? s : m_stripHtmlElements.Replace(s, string.Empty));
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
        public static string LowerFirstLetter(this string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(Char.ToLowerInvariant(s[0]) + s.Substring(1));
        }
예제 #4
0
        public static bool HasMagicRegexChars(string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(-1 != s.IndexOfAny(MagicRegexChars));
        }
예제 #5
0
        /// <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));
        }
예제 #6
0
        public static string SpacePascalOrCamel(this string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(m_pascalOrCamelRegex.Replace(s, "$1 ").ChopRight(1));
        }
예제 #7
0
 public static bool OicContains(this string s, string [] candidates)
 {
     ArgumentValidator.ThrowIfNull(s, "s");
     ArgumentValidator.ThrowIfNull(candidates, "candidates");
     return(candidates.Any(candidate => s.OicContains(candidate)));
 }
예제 #8
0
        public static Type GetUnderlyingType(this Type t)
        {
            ArgumentValidator.ThrowIfNull(t, "t");

            return(Nullable.GetUnderlyingType(t) ?? t);
        }
예제 #9
0
        public static string EncodeHtml(this string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(HttpUtility.HtmlEncode(s));
        }
예제 #10
0
        public static string ToAbsolute(this string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(VirtualPathUtility.ToAbsolute(s));
        }
예제 #11
0
        public static string ToNullIfEmpty(string s)
        {
            ArgumentValidator.ThrowIfNull(s, "s");

            return(0 == s.Length ? null : s);
        }
예제 #12
0
        /// <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());
        }
예제 #13
0
        public static string FormatJson(this string format, params object[] args)
        {
            ArgumentValidator.ThrowIfNull(format, "format");

            return(string.Format(JsonFormatter.Instance, format, args));
        }
예제 #14
0
        public static bool OicEquals(this string s1, string s2)
        {
            ArgumentValidator.ThrowIfNull(s1, "s1");

            return(null != s2 && s1.Equals(s2, StringComparison.OrdinalIgnoreCase));
        }
예제 #15
0
 public static bool IsValidEmailAddress(this string s)
 {
     ArgumentValidator.ThrowIfNull(s, "s");
     return(EmailPattern.IsMatch(s));
 }
예제 #16
0
        public static bool IsNumeric(Type t)
        {
            ArgumentValidator.ThrowIfNull(t, "t");

            return(IsIntegralType(t) || IsFloatingPoint(t));
        }
예제 #17
0
 public static int OicLastIndexOf(this string s, string candidate)
 {
     ArgumentValidator.ThrowIfNull(s, "s");
     ArgumentValidator.ThrowIfNull(candidate, "candidate");
     return(s.LastIndexOf(candidate, StringComparison.OrdinalIgnoreCase));
 }
예제 #18
0
        public object GetAnnotation(string annotation)
        {
            ArgumentValidator.ThrowIfNullOrEmpty(annotation, "annotation");

            return(this.GetAnnotation(this.TableChanges.GetAnnotationIdx(annotation)));
        }
예제 #19
0
        /// <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;
        }