Пример #1
0
        /// <summary>
        /// Writes value of given column of given data row as identifier to given
        /// string builder with given prefix if this value was changed.
        /// </summary>
        /// <param name="row">Data row to extract value.</param>
        /// <param name="column">Column name to look for value.</param>
        /// <param name="prefix">Prefix to write before.</param>
        /// <param name="suffix">Suffix to write after.</param>
        /// <param name="target">String builder to write.</param>
        public static void WriteIdentifierIfChanged(DataRow row, string column, string prefix, string suffix, StringBuilder target)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (DataInterpreter.HasChanged(row, column))
            {
                if (!String.IsNullOrEmpty(prefix))
                {
                    target.Append(prefix);
                }
                target.Append(EscapeAndQuoteIdentifier(DataInterpreter.GetString(row, column)));
                if (!String.IsNullOrEmpty(suffix))
                {
                    target.Append(suffix);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Writes value of given column of given data row to given string builder.
        /// </summary>
        /// <param name="row">Data row to extract value.</param>
        /// <param name="column">Column name to look for value.</param>
        /// <param name="target">String builder to write.</param>
        /// <param name="quote">Indicates if value should be quoted.</param>
        public static void WriteValue(DataRow row, string column, StringBuilder target, bool quote)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            // Reading string value
            string toWrite = DataInterpreter.GetString(row, column);

            // If value is not integer, we need quotes and empty strings are allowed
            if (!DataInterpreter.IsInteger(row, column))
            {
                // Substitute null with empty string
                if (toWrite == null)
                {
                    toWrite = String.Empty;
                }
                if (quote)
                {
                    toWrite = EscapeAndQuoteString(toWrite);
                }
            }

            // Append values
            target.Append(toWrite);
        }
Пример #3
0
        /// <summary>
        /// Writes value of given column of given data row to given string builder with
        /// given prefix if this value was changed.
        /// </summary>
        /// <param name="row">Data row to extract value.</param>
        /// <param name="column">Column name to look for value.</param>
        /// <param name="prefix">Prefix to write.</param>
        /// <param name="target">String builder to write.</param>
        /// <param name="suffix">Suffix to append after value.</param>
        /// <param name="quote">Indicates if value should be quoted.</param>
        public static void WriteIfChanged(DataRow row, string column, string prefix, StringBuilder target, string suffix, bool quote)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (DataInterpreter.HasChanged(row, column))
            {
                if (!String.IsNullOrEmpty(prefix))
                {
                    target.Append(prefix);
                }
                WriteValue(row, column, target, quote);
                if (!String.IsNullOrEmpty(suffix))
                {
                    target.Append(suffix);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Extracts otions form the value of given column of given data row into
        /// key-value ductionary. " " is used as fields delimeter and "=" it used
        /// as key-value delimeter.
        /// </summary>
        /// <param name="row">DataRow with values to check.</param>
        /// <param name="column">Column name.</param>
        /// <returns>Returns dictionary with extracted fields</returns>
        public static Dictionary <string, string> ExtractFieldsDictionary(DataRow row, string column)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }

            return(ExtractFieldsDictionary(DataInterpreter.GetString(row, column)));
        }
Пример #5
0
        /// <summary>
        /// Checks value of given column of given row for emptiness,
        /// considering value as string. Works with default data row
        /// version.
        /// </summary>
        /// <param name="row">DataRow with values to check.</param>
        /// <param name="column">Column name.</param>
        /// <returns>
        /// Returns true, if value of given column of given row is not empty string,
        /// and false otherwise.
        /// </returns>
        public static bool IsNotEmptyString(DataRow row, string column)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }

            return(DataInterpreter.IsNotEmptyString(row, column, DataRowVersion.Default));
        }
Пример #6
0
        /// <summary>
        /// Writes original value of given column of given data row as identifier
        /// to given string builder.
        /// </summary>
        /// <param name="row">Data row to extract value.</param>
        /// <param name="column">Column name to look for value.</param>
        /// <param name="target">String builder to write.</param>
        public static void WriteOldIdentifier(DataRow row, string column, StringBuilder target)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            target.Append(EscapeAndQuoteIdentifier(DataInterpreter.GetString(row, column, DataRowVersion.Original)));
        }
Пример #7
0
        /// <summary>
        /// Writes given expression to given string builder if value in given column
        /// of given data row is equivalent to False.
        /// </summary>
        /// <param name="row">Data row to extract value.</param>
        /// <param name="column">Column name to look for value.</param>
        /// <param name="expression">Expression to write to string builder.</param>
        /// <param name="target">String builder to write.</param>
        public static void WriteIfFalse(DataRow row, string column, string expression, StringBuilder target)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (!DataInterpreter.GetSqlBool(row, column))
            {
                target.Append(expression);
            }
        }