protected override void Execute()
        {
            String path      = this.OutputDirectoryPath;
            var    tablePath = Path.Combine(path, "Table");
            var    tableStoredProcedurePath = Path.Combine(path, "TableStoredProcedure");
            var    storedProcedurePath      = Path.Combine(path, "StoredProcedure");
            var    userDefinedTableTypePath = Path.Combine(path, "UserDefinedTableType");

            ClassSourceCodeFileFactory f = null;
            var sc = new SourceCodeFileGenerator();

            foreach (var table in this.Tables)
            {
                f = new TableClassSourceCodeFileFactory(table, this.DatabaseKey);
                sc.SourceCodes.Add(f.Create(tablePath, this.NamespaceName));
                f = new TableRecordClassSourceCodeFileFactory(table);
                sc.SourceCodes.Add(f.Create(tablePath, this.NamespaceName));
                f = new TableIRecordClassSourceCodeFileFactory(table);
                sc.SourceCodes.Add(f.Create(tablePath, this.NamespaceName));
            }
            foreach (var sp in this.StoredProcedures.Where(el => el.StoredProcedureType != StoredProcedureType.Custom))
            {
                f = new StoredProcedureClassSourceCodeFileFactory(sp, this.DatabaseKey);
                sc.SourceCodes.Add(f.Create(tableStoredProcedurePath, this.NamespaceName));
            }
            foreach (var sp in this.StoredProcedures.Where(el => el.StoredProcedureType == StoredProcedureType.Custom))
            {
                f = new StoredProcedureClassSourceCodeFileFactory(sp, this.DatabaseKey);
                sc.SourceCodes.Add(f.Create(storedProcedurePath, this.NamespaceName));
            }
            foreach (var ut in this.UserDefinedTableTypes)
            {
                f = new UserDefinedTableTypeSourceCodeFileClassFactory(ut);
                sc.SourceCodes.Add(f.Create(userDefinedTableTypePath, this.NamespaceName));
            }

            var count = sc.SourceCodes.Count;

            for (int i = 0; i < count; i++)
            {
                var file = sc.SourceCodes[i];
                CSharpSourceCodeGenerator cs = null;

                using (var stm = new StreamWriter(file.FilePath, false, Encoding.UTF8))
                {
                    foreach (var c in String.Format("{0}{1}", GeneratedByComment, Environment.NewLine))
                    {
                        stm.Write(c);
                    }
                    cs = new CSharpSourceCodeGenerator(stm);
                    cs.Write(file.SourceCode);
                    this.OnProcessProgress(new ProcessProgressEventArgs(Path.GetFileName(file.FilePath), i / count));
                    this.OnFileGenerated(new SourceCodeFileGeneratedEventArgs(file, DateTime.Now));
                }
            }
        }
        protected override void Execute()
        {
            String path = this.OutputDirectoryPath;
            var tablePath = path + "Table";
            var tableStoredProcedurePath = path + "TableStoredProcedure";
            var storedProcedurePath = path + "StoredProcedure";
            var userDefinedTableTypePath = path + "UserDefinedTableType";

            ClassSourceCodeFileFactory f = null;
            var sc = new SourceCodeFileGenerator();
            foreach (var table in this.Tables)
            {
                f = new TableClassSourceCodeFileFactory(table, this.DatabaseKey);
                sc.SourceCodes.Add(f.Create(tablePath, this.NamespaceName));
                f = new TableRecordClassSourceCodeFileFactory(table);
                sc.SourceCodes.Add(f.Create(tablePath, this.NamespaceName));
                f = new TableIRecordClassSourceCodeFileFactory(table);
                sc.SourceCodes.Add(f.Create(tablePath, this.NamespaceName));
            }
            foreach (var sp in this.StoredProcedures.Where(el => el.StoredProcedureType != StoredProcedureType.Custom))
            {
                f = new StoredProcedureClassSourceCodeFileFactory(sp, this.DatabaseKey);
                sc.SourceCodes.Add(f.Create(tableStoredProcedurePath, this.NamespaceName));
            }
            foreach (var sp in this.StoredProcedures.Where(el => el.StoredProcedureType == StoredProcedureType.Custom))
            {
                f = new StoredProcedureClassSourceCodeFileFactory(sp, this.DatabaseKey);
                sc.SourceCodes.Add(f.Create(storedProcedurePath, this.NamespaceName));
            }
            foreach (var ut in this.UserDefinedTableTypes)
            {
                f = new UserDefinedTableTypeSourceCodeFileClassFactory(ut);
                sc.SourceCodes.Add(f.Create(userDefinedTableTypePath, this.NamespaceName));
            }

            var count = sc.SourceCodes.Count;
            for (int i = 0; i < count; i++)
            {
                var file = sc.SourceCodes[i];
                CSharpSourceCodeGenerator cs = null;

                using (var stm = new StreamWriter(file.FilePath, false, Encoding.UTF8))
                {
                    cs = new CSharpSourceCodeGenerator(stm);
                    cs.Write(file.SourceCode);
                    this.OnProcessProgress(new ProcessProgressEventArgs(Path.GetFileName(file.FilePath), i / count));
                    this.OnFileGenerated(new SourceCodeFileGeneratedEventArgs(file, DateTime.Now));
                }
            }
        }