Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Converts given column of given row to string value. Works with
        /// default data row version.
        /// </summary>
        /// <param name="row">DataRow with values to check.</param>
        /// <param name="column">Column name.</param>
        /// <returns>
        /// Returns string representation of the value or null, if value is empty.
        /// </returns>
        public static string GetString(DataRow row, string column)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (String.IsNullOrEmpty(column))
            {
                throw new ArgumentException(Resources.Error_EmptyString, "column");
            }

            return(DataInterpreter.GetString(row, column, DataRowVersion.Default));
        }
Exemplo n.º 5
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)));
        }