/// <summary>
        /// Serializes the schema of a DataTable into to a Tiferix JsonTableSchema object which can then be stored in a JsonDataSetSchema file.
        /// This version of the function will also be used internally to serialize a DataSet or DataTable into a JsonDataSetSchema/JsonTableSchema
        /// object before writing the schema information to a data stream or file on disk.
        /// </summary>
        /// <param name="dtSchema">DataTable with schema to be serialized to JsonTableSchema object.</param>
        /// <returns></returns>
        public virtual JsonTableSchema SerializeTableSchema(DataTable dtSchema)
        {
            try
            {
                JsonTableSchema tblSchema = new Data.JsonTableSchema();

                foreach (DataColumn column in dtSchema.Columns)
                {
                    JsonColumnSchema colSchema = new JsonColumnSchema();
                    colSchema.ColumnName        = column.ColumnName;
                    colSchema.DataType          = column.DataType;
                    colSchema.Unique            = column.Unique;
                    colSchema.MaxLength         = column.MaxLength;
                    colSchema.AllowDBNull       = column.AllowDBNull;
                    colSchema.AutoIncrement     = column.AutoIncrement;
                    colSchema.AutoIncrementSeed = column.AutoIncrementSeed;
                    colSchema.AutoIncrementStep = column.AutoIncrementStep;
                    colSchema.Caption           = column.Caption;
                    colSchema.DateTimeMode      = column.DateTimeMode;
                    colSchema.DefaultValue      = column.DefaultValue;
                    colSchema.Expression        = column.Expression;
                    colSchema.ReadOnly          = column.ReadOnly;

                    if (dtSchema.PrimaryKey != null)
                    {
                        if (dtSchema.PrimaryKey.Contains(column))
                        {
                            colSchema.PrimaryKey = true;
                        }
                    }//end if

                    tblSchema.Columns.Add(colSchema);
                }//next colSchema

                return(tblSchema);
            }
            catch (Exception err)
            {
                ErrorHandler.ShowErrorMessage(err, "Error in SerializeTableSchema Overload 1 function of JsonDataSetSchemaSerializer class.");
                return(null);
            }
        }
        /// <summary>
        /// An internal function that will use a JsonDataWriter object to serialize the data stored in a JsonTableSchema object to a JsonDataSetSchema
        /// data stream or file.  The JsonTableSchema object will have been previously loaded before the function is called and the JsonDataWriter
        /// will be positioned at the next table schema record in the data stream.
        /// </summary>
        /// <param name="jwrtSchema">JsonDataWriter object used for serializing the schema information of the DataTable to the JsonDataSetSchema
        /// data stream.</param>
        /// <param name="tblSchema">The JsonTableSchema object containing all the schema information of a DataTable to serialize to the JsonDataSetSchema
        /// data stream.</param>
        protected virtual void SerializeTableSchema(JsonDataWriter jwrtSchema, JsonTableSchema tblSchema)
        {
            try
            {
                //Writes opening '{' object bracket of either Tables schema array (of DataSet Schema file) or of the entire table schema file.
                jwrtSchema.WriteBeginObject();

                //"Table": "Table Name",
                jwrtSchema.WritePropDataValue("Table", tblSchema.TableName, true);

                //"Columns": [
                jwrtSchema.WritePropertyName("Columns");
                jwrtSchema.WriteBeginArray(true);

                //Loops through each column of the table schema and serializes the data to the stream.
                for (int iColIndex = 0; iColIndex < tblSchema.Columns.Count; iColIndex++)
                {
                    JsonColumnSchema colSchema = tblSchema.Columns[iColIndex];

                    //Write opening '{' object bracket for the column schema.
                    jwrtSchema.WriteBeginObject();

                    jwrtSchema.WritePropDataValue("ColumnName", colSchema.ColumnName, true);
                    jwrtSchema.WritePropDataValue("DataType", JsonDataUtils.ConvertToJsonDataType(colSchema.DataType), true);
                    jwrtSchema.WritePropDataValue("PrimaryKey", colSchema.PrimaryKey, true);
                    jwrtSchema.WritePropDataValue("Unique", colSchema.Unique, true);
                    jwrtSchema.WritePropDataValue("MaxLength", colSchema.MaxLength, true);
                    jwrtSchema.WritePropDataValue("AllowDBNull", colSchema.AllowDBNull, true);
                    jwrtSchema.WritePropDataValue("AutoIncrement", colSchema.AutoIncrement, true);
                    jwrtSchema.WritePropDataValue("AutoIncrementSeed", colSchema.AutoIncrementSeed, true);
                    jwrtSchema.WritePropDataValue("AutoIncrementStep", colSchema.AutoIncrementStep, true);
                    jwrtSchema.WritePropDataValue("Caption", colSchema.Caption, true);
                    jwrtSchema.WritePropDataValue("DateTimeMode", colSchema.DateTimeMode.ToString(), true);

                    if (colSchema.DefaultValue != null)
                    {
                        jwrtSchema.WritePropDataValue("DefaultValue", colSchema.DefaultValue.ToString(), true);
                    }
                    else
                    {
                        jwrtSchema.WritePropDataNullValue("DefaultValue", true);
                    }

                    jwrtSchema.WritePropDataValue("ReadOnly", colSchema.ReadOnly);

                    //Write closing '}' object bracket for the column schema.
                    jwrtSchema.WriteEndObject();

                    if (iColIndex < tblSchema.Columns.Count - 1)
                    {
                        //Writes comma field delimiter after the column end object to separate each column record.
                        jwrtSchema.WriteFieldDelimiter();
                    }
                    else
                    {
                        //The final column record will have a closing object bracket without a comma.
                        jwrtSchema.WriteNewLine();
                    }
                }//next iColIndex

                //Writes closing ']' of columns array.
                jwrtSchema.WriteEndArray();

                //Writes closing '}' object bracket of either Tables schema array (of DataSet Schema file) or of the entire table schema file.
                jwrtSchema.WriteEndObject();
            }
            catch (Exception err)
            {
                ErrorHandler.ShowErrorMessage(err, "Error in SerializeTableSchema Overload 2 function of JsonDataSetSchemaSerializer class.");
            }
        }