// ----------------------------------------------------------------------------------------
        /// <!-- IfUnequal -->
        /// <summary>
        ///      Throws an exception if the two objects are not the same when they should be
        /// </summary>
        /// <param name="objA"></param>
        /// <param name="objB"></param>
        /// <param name="descrA"></param>
        /// <param name="descrB"></param>
        /// <param name="place"></param>
        /// <returns>returns true if they are equal</returns>
        public static bool IfUnequal(object objA, object objB, string descrA, string descrB, string place)
        {
            string message = "";
            bool   equal   = (objA == objB);


            if (!equal)
            {
                // ----------------------------------------------------------------------
                //  Inequality message
                // ----------------------------------------------------------------------
                if (objA == null)
                {
                    message = descrA + " is null and " + descrB + " is not at " + place;
                }
                else if (objB == null)
                {
                    message = descrB + " is null and " + descrA + " is not at " + place;
                }
                else
                {
                    message = descrA + " does not match " + descrB + " at " + place + "."
                              + "\r\n'" + objA.ToString() + "' != '" + objB.ToString() + "'";
                }
                ThrowMessage.A(new DataException(message));
            }


            return(equal);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- EventSourceBuild -->
        /// <summary>
        ///      Builds the event source creation data for logging using source and log names
        /// </summary>
        /// <param name="source">often a project name</param>
        /// <param name="logName"></param>
        /// <returns>constructed event source</returns>
        public static EventSourceCreationData EventSourceBuild(string source, string logName)
        {
            EventSourceCreationData eventSource;

            eventSource             = new EventSourceCreationData(source, logName);
            eventSource.MachineName = ThrowMessage.SetLocalMachineName(); // local machine
            _eventSource            = eventSource;
            return(eventSource);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- IfTooLong -->
        /// <summary>
        ///      Throws an exception if the string is too long
        /// </summary>
        /// <param name="str"></param>
        /// <param name="maxLength"></param>
        /// <returns>returns true if string is too long</returns>
        public static bool IfTooLong(string str, int maxLength)
        {
            bool tooLong = true;

            if (str != null && str.Length > maxLength)
            {
                ThrowMessage.A(new OverflowException("string too long: " + str.Length + ">" + maxLength));
            }
            else
            {
                tooLong = false;
            }
            return(tooLong);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- IfNullOrEmpty -->
        /// <summary>
        ///      Throws if the string is null or empty and returns a boolean
        /// </summary>
        /// <param name="str"></param>
        /// <param name="message">returns true if the string is null or empty</param>
        public static bool IfNullOrEmpty(string str, string message)
        {
            bool isBlank = true;

            if (string.IsNullOrEmpty(str))
            {
                ThrowMessage.A(new NoNullAllowedException(message));
            }
            else
            {
                isBlank = false;
            }
            return(isBlank);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- IfNull -->
        /// <summary>
        ///      Throws if the object is null and returns a boolean
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="message"></param>
        /// <returns>returns true if the object is null</returns>
        public static bool IfNull(object obj, string message)
        {
            bool isNull = true;

            if (obj == null)
            {
                ThrowMessage.A(new NoNullAllowedException(message));
            }
            else
            {
                isNull = false;
            }
            return(isNull);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- IfNotMatch -->
        /// <summary>
        ///      Throws if the string does not match the patter and returns a boolean
        /// </summary>
        /// <param name="str"></param>
        /// <param name="pattern"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool IfNotMatch(string str, string pattern, string message)
        {
            bool notMatch = true;

            if (!Regex.IsMatch(str, pattern))
            {
                ThrowMessage.A(new FormatException(message + ": " + str));
            }
            else
            {
                notMatch = false;
            }
            return(notMatch);
        }