private CodeTypeDeclaration CreateDataSourceDeclaration(DesignDataSource dtDataSource)
 {
     if (dtDataSource.Name == null)
     {
         throw new DataSourceGeneratorException("DataSource name cannot be null.");
     }
     new NameHandler(this.codeProvider).GenerateMemberNames(dtDataSource, this.problemList);
     CodeTypeDeclaration dataSourceClass = CodeGenHelper.Class(dtDataSource.GeneratorDataSetName, true, dtDataSource.Modifier);
     dataSourceClass.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(DataSet)));
     dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.Serializable"));
     dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.DesignerCategoryAttribute", CodeGenHelper.Str("code")));
     dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.ToolboxItem", CodeGenHelper.Primitive(true)));
     dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(XmlSchemaProviderAttribute).FullName, CodeGenHelper.Primitive("GetTypedDataSetSchema")));
     dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(XmlRootAttribute).FullName, CodeGenHelper.Primitive(dtDataSource.GeneratorDataSetName)));
     dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(HelpKeywordAttribute).FullName, CodeGenHelper.Str("vs.data.DataSet")));
     dataSourceClass.Comments.Add(CodeGenHelper.Comment("Represents a strongly typed in-memory cache of data.", true));
     this.tableHandler = new TypedTableHandler(this, dtDataSource.DesignTables);
     this.relationHandler = new System.Data.Design.RelationHandler(this, dtDataSource.DesignRelations);
     this.rowHandler = new TypedRowHandler(this, dtDataSource.DesignTables);
     DatasetMethodGenerator generator = new DatasetMethodGenerator(this, dtDataSource);
     this.tableHandler.AddPrivateVars(dataSourceClass);
     this.tableHandler.AddTableProperties(dataSourceClass);
     this.relationHandler.AddPrivateVars(dataSourceClass);
     generator.AddMethods(dataSourceClass);
     this.rowHandler.AddTypedRowEventHandlers(dataSourceClass);
     this.tableHandler.AddTableClasses(dataSourceClass);
     this.rowHandler.AddTypedRows(dataSourceClass);
     this.rowHandler.AddTypedRowEventArgs(dataSourceClass);
     return dataSourceClass;
 }
        private CodeTypeDeclaration CreateDataSourceDeclaration(DesignDataSource dtDataSource)
        {
            if (dtDataSource.Name == null)
            {
                throw new DataSourceGeneratorException("DataSource name cannot be null.");
            }
            new NameHandler(this.codeProvider).GenerateMemberNames(dtDataSource, this.problemList);
            CodeTypeDeclaration dataSourceClass = CodeGenHelper.Class(dtDataSource.GeneratorDataSetName, true, dtDataSource.Modifier);

            dataSourceClass.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(DataSet)));
            dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.Serializable"));
            dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.DesignerCategoryAttribute", CodeGenHelper.Str("code")));
            dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.ToolboxItem", CodeGenHelper.Primitive(true)));
            dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(XmlSchemaProviderAttribute).FullName, CodeGenHelper.Primitive("GetTypedDataSetSchema")));
            dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(XmlRootAttribute).FullName, CodeGenHelper.Primitive(dtDataSource.GeneratorDataSetName)));
            dataSourceClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(HelpKeywordAttribute).FullName, CodeGenHelper.Str("vs.data.DataSet")));
            dataSourceClass.Comments.Add(CodeGenHelper.Comment("Represents a strongly typed in-memory cache of data.", true));
            this.tableHandler    = new TypedTableHandler(this, dtDataSource.DesignTables);
            this.relationHandler = new System.Data.Design.RelationHandler(this, dtDataSource.DesignRelations);
            this.rowHandler      = new TypedRowHandler(this, dtDataSource.DesignTables);
            DatasetMethodGenerator generator = new DatasetMethodGenerator(this, dtDataSource);

            this.tableHandler.AddPrivateVars(dataSourceClass);
            this.tableHandler.AddTableProperties(dataSourceClass);
            this.relationHandler.AddPrivateVars(dataSourceClass);
            generator.AddMethods(dataSourceClass);
            this.rowHandler.AddTypedRowEventHandlers(dataSourceClass);
            this.tableHandler.AddTableClasses(dataSourceClass);
            this.rowHandler.AddTypedRows(dataSourceClass);
            this.rowHandler.AddTypedRowEventArgs(dataSourceClass);
            return(dataSourceClass);
        }