/// <summary>
        /// This method writes the summary for the data object reader.
        /// </summary>
        /// <param name="dataTable"></param>
        private void WriteClassSummary(DataTable dataTable, dataObjects.CustomReader customReader = null)
        {
            // write the open summary tag
            WriteLine("/// <summary>");

            WriteLine("/// This class loads a single '" + dataTable.ClassName + "' object or a list of type <" + dataTable.ClassName + ">.");

            // write the closing summary
            WriteLine("/// </summary>");
        }
        /// <summary>
        /// This method writes the field integers for this data table.
        /// </summary>
        /// <param name="dataTable"></param>
        private List <DataField> WriteFieldIntegers(DataTable dataTable, dataObjects.CustomReader customReader = null)
        {
            // update to handle CustomReaders: Now the list of DataFields is set from either the
            // CustomReader.FieldSet or the DataTabe.ActiveFields
            List <DataField> fields = null;

            // Write Blank line
            WriteLine();

            // Write Comment Create field Integers
            WriteComment("Create field Integers");

            // local for ordinalPosition
            int ordinalPosition = 0;

            // if the customReader exists and has a FieldSet
            if ((NullHelper.Exists(customReader)) && (customReader.HasFieldSet) && (customReader.FieldSet.HasFields))
            {
                // convert the CustomReader fields to DataField objects
                fields = DataConverter.ConvertDataFields(customReader.FieldSet.Fields);
            }
            // if dataTable exists
            else if (dataTable != null)
            {
                // only use the ActiveFields to ignore unwanted fields
                fields = dataTable.ActiveFields;
            }

            // If the fields collection exists and has one or more items
            if (ListHelper.HasOneOrMoreItems(fields))
            {
                // loop through each field
                for (int x = 0; x < fields.Count; x++)
                {
                    // Get The Current field
                    DataField field = fields[x];

                    // Set OrdinalPosition
                    ordinalPosition = x;

                    // Write the fieldLine for this field
                    WriteFieldIntegerLine(field, ordinalPosition);
                }

                // Write Blank Line
                WriteLine();
            }

            // return value
            return(fields);
        }
        /// <summary>
        /// Create the file name for this reader.
        /// </summary>
        /// <param name="dataTable"></param>
        /// <returns></returns>
        private string CreateFileName(DataTable dataTable, dataObjects.CustomReader customReader = null)
        {
            // Create StringBuilder
            StringBuilder sb = new StringBuilder();

            // Append RootDataObjectReaderPath
            sb.Append(this.RootDataObjectReaderPath);

            // If the root data object reader path does not end with a back slash
            if (!this.RootDataObjectReaderPath.EndsWith(@"\"))
            {
                // Append Backslash
                sb.Append(@"\");
            }

            // If the customReader object exists
            if (NullHelper.Exists(customReader))
            {
                // Add ClassName
                sb.Append(customReader.ReaderName);

                // append .cs extension
                sb.Append(".cs");
            }
            else
            {
                // Add ClassName
                sb.Append(dataTable.ClassName.Replace("_", ""));

                // Add The Word Reader
                sb.Append("Reader.cs");
            }

            // return value
            return(sb.ToString());
        }
        /// <summary>
        /// This method writes the Load method for a DataTable.
        /// </summary>
        /// <param name="dataTable"></param>
        private List <DataField> WriteLoadMethod(DataTable dataTable, dataObjects.CustomReader customReader = null)
        {
            // update to handle CustomReaders: Now the list of DataFields is set from either the
            // CustomReader.FieldSet or the DataTabe.ActiveFields
            List <DataField> fields = null;

            // If the data table exists
            if (dataTable != null)
            {
                // Write Blank Line
                WriteLine();

                // Write BeginRegion
                BeginRegion("Load(DataRow dataRow)");

                // Write Load Method Summary
                WriteLoadMethodSummary(dataTable);

                // Create loadMethodLine
                string loadMethodLine = "public static " + GetClassName(dataTable) + " Load(DataRow dataRow)";

                // Write LoadMethodLine
                WriteLine(loadMethodLine);

                // Write Open Bracket
                WriteOpenBracket();

                // Increase Indent
                Indent++;

                // Write Comment For Initial Value
                WriteComment("Initial Value");

                // Create Object Line
                string objectLine = CreateObjectLine(dataTable);

                // Write Object Line
                WriteLine(objectLine);

                // Write field Integers
                fields = WriteFieldIntegers(dataTable, customReader);

                // Write try
                WriteLine("try");

                // Write Open Bracket
                WriteOpenBracket();

                // Increase Indent
                Indent++;

                // Write Comment Load Each field
                WriteComment("Load Each field");

                // create objectName
                string objectName = CapitalizeFirstChar(GetClassName(dataTable), true);

                // variable for each field to load
                string loadField = null;

                // If the fields collection exists and has one or more items
                if (ListHelper.HasOneOrMoreItems(fields))
                {
                    // add each field
                    foreach (DataField field in fields)
                    {
                        // do not write the primary key
                        if ((!field.PrimaryKey) || (dataTable.IsView))
                        {
                            // load this field
                            loadField = CreateLoadFieldLine(field, objectName);

                            // Write Line To LoadF This field
                            WriteLine(loadField);
                        }
                        else
                        {
                            // Now Write Update Identity Method
                            WriteUpdateIdentity(dataTable, objectName);
                        }
                    }
                }

                // Decrease Indent
                Indent--;

                // Write Close Bracket
                WriteLine("}");

                // Write catch
                WriteLine("catch");

                // Write Open Bracket
                WriteOpenBracket();

                // Write Close Bracket
                WriteLine("}");

                // Write Blank Line
                WriteLine();

                // write Comment For Return Value
                WriteComment("return value");

                // Write Return Value
                string returnValue = "return " + objectName + ";";
                WriteLine(returnValue);

                // Decrease Indent
                Indent--;

                // Write Close Bracket
                WriteLine("}");

                // Write endregion
                WriteLine("#endregion");
            }

            // return value
            return(fields);
        }
        /// <summary>
        /// Create an object reader for the table passed in.
        /// </summary>
        public List <DataField> CreateObjectReader(DataTable dataTable, dataObjects.CustomReader customReader = null)
        {
            // initial value
            List <DataField> dataFields = null;

            // Set Indent To 0
            Indent = 0;

            // verify DataTable exist
            if (dataTable != null)
            {
                // Get DataWatcherFileName
                string fileName = CreateFileName(dataTable, customReader);

                // Create Writer
                CreateFile(fileName, DataManager.ProjectTypeEnum.DAC);

                // Write References
                WriteReferences(this.ObjectReferences);

                // Write Blank Line
                WriteLine();

                // Write NameSpace
                string nameSpace = "namespace " + this.NameSpaceName;
                WriteLine(nameSpace);

                // Write Open Brack
                WriteOpenBracket();

                // Write Blank Line
                WriteLine();

                // Increase Indent
                Indent++;

                // Get ClassName
                string className = dataTable.ClassName + "Reader";

                // If the customReader object exists
                if (NullHelper.Exists(customReader))
                {
                    // set the className
                    className = customReader.ClassName;
                }

                // Write Region for this reader
                BeginRegion("class " + className);

                // Write Object Reader Summary
                WriteClassSummary(dataTable, customReader);

                // get class line
                string classLine = "public class " + className;

                // Write ClassLine
                WriteLine(classLine);

                // Write Open Brack
                WriteOpenBracket();

                // Write Blank Line
                WriteLine();

                // Increase Indent
                Indent++;

                // Begin Region Static Methods
                BeginRegion("Static Methods");

                // Increase Indent
                Indent++;

                // Write Load Method
                dataFields = WriteLoadMethod(dataTable, customReader);

                // Write LoadCollectionMethod
                WriteLoadCollectionMethod(dataTable);

                // Decrease Indent
                Indent--;

                // Write line
                WriteLine("#endregion");

                // Write Blank Line
                WriteLine();

                // Decrease Indent
                Indent--;

                // Write Close Bracket
                WriteLine("}");

                // Write EndRegion
                WriteLine("#endregion");

                // Write Blank Line
                WriteLine();

                // Decrease Indent
                Indent--;

                // Write Close Bracket
                WriteLine("}");

                // Close This File
                this.Writer.Close();
            }

            // return value
            return(dataFields);
        }