private CodeTypeDeclaration CreateTypedRowEventArg(DesignTable designTable)
        {
            if (designTable == null)
            {
                throw new InternalException("DesignTable should not be null.");
            }
            DataTable           dataTable               = designTable.DataTable;
            string              generatorRowClassName   = designTable.GeneratorRowClassName;
            string              generatorTableClassName = designTable.GeneratorTableClassName;
            string              type        = designTable.GeneratorRowClassName;
            CodeTypeDeclaration declaration = CodeGenHelper.Class(designTable.GeneratorRowEvArgName, false, TypeAttributes.Public);

            declaration.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(EventArgs)));
            declaration.Comments.Add(CodeGenHelper.Comment("Row event argument class", true));
            declaration.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.Type(type), "eventRow"));
            declaration.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(typeof(DataRowAction)), "eventAction"));
            declaration.Members.Add(this.EventArgConstructor(type));
            CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.Type(type), "Row", MemberAttributes.Public | MemberAttributes.Final);

            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), "eventRow")));
            declaration.Members.Add(property);
            property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(typeof(DataRowAction)), "Action", MemberAttributes.Public | MemberAttributes.Final);
            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), "eventAction")));
            declaration.Members.Add(property);
            return(declaration);
        }
        private void AddTransactionMembers(CodeTypeDeclaration dataComponentClass)
        {
            Type transactionType = this.designTable.PropertyCache.TransactionType;

            if (transactionType != null)
            {
                CodeTypeReference type = CodeGenHelper.GlobalType(transactionType);
                dataComponentClass.Members.Add(CodeGenHelper.FieldDecl(type, DataComponentNameHandler.TransactionVariableName));
                CodeMemberProperty property = CodeGenHelper.PropertyDecl(type, DataComponentNameHandler.TransactionPropertyName, MemberAttributes.Assembly | MemberAttributes.Final);
                property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.TransactionVariableName)));
                property.SetStatements.Add(CodeGenHelper.Assign(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.TransactionVariableName), CodeGenHelper.Argument("value")));
                CodeStatement  initStmt       = CodeGenHelper.VariableDecl(CodeGenHelper.Type(typeof(int)), "i", CodeGenHelper.Primitive(0));
                CodeExpression testExpression = CodeGenHelper.Less(CodeGenHelper.Variable("i"), CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), "Length"));
                CodeStatement  incrementStmt  = CodeGenHelper.Assign(CodeGenHelper.Variable("i"), CodeGenHelper.BinOperator(CodeGenHelper.Variable("i"), CodeBinaryOperatorType.Add, CodeGenHelper.Primitive(1)));
                CodeExpression transaction    = CodeGenHelper.Property(CodeGenHelper.Indexer(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), CodeGenHelper.Variable("i")), "Transaction");
                CodeExpression oldTransaction = CodeGenHelper.Variable("oldTransaction");
                CodeExpression newTransaction = CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.TransactionVariableName);
                CodeStatement  statement3     = this.GenerateSetTransactionStmt(transaction, oldTransaction, newTransaction);
                property.SetStatements.Add(CodeGenHelper.ForLoop(initStmt, testExpression, incrementStmt, new CodeStatement[] { statement3 }));
                CodeExpression exp         = CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName);
                CodeExpression expression6 = CodeGenHelper.Property(exp, "DeleteCommand");
                transaction = CodeGenHelper.Property(expression6, "Transaction");
                property.SetStatements.Add(CodeGenHelper.If(CodeGenHelper.And(CodeGenHelper.IdNotEQ(exp, CodeGenHelper.Primitive(null)), CodeGenHelper.IdNotEQ(expression6, CodeGenHelper.Primitive(null))), this.GenerateSetTransactionStmt(transaction, oldTransaction, newTransaction)));
                expression6 = CodeGenHelper.Property(exp, "InsertCommand");
                transaction = CodeGenHelper.Property(expression6, "Transaction");
                property.SetStatements.Add(CodeGenHelper.If(CodeGenHelper.And(CodeGenHelper.IdNotEQ(exp, CodeGenHelper.Primitive(null)), CodeGenHelper.IdNotEQ(expression6, CodeGenHelper.Primitive(null))), this.GenerateSetTransactionStmt(transaction, oldTransaction, newTransaction)));
                expression6 = CodeGenHelper.Property(exp, "UpdateCommand");
                transaction = CodeGenHelper.Property(expression6, "Transaction");
                property.SetStatements.Add(CodeGenHelper.If(CodeGenHelper.And(CodeGenHelper.IdNotEQ(exp, CodeGenHelper.Primitive(null)), CodeGenHelper.IdNotEQ(expression6, CodeGenHelper.Primitive(null))), this.GenerateSetTransactionStmt(transaction, oldTransaction, newTransaction)));
                dataComponentClass.Members.Add(property);
            }
        }
        private void AddClearBeforeFillMembers(CodeTypeDeclaration dataComponentClass)
        {
            dataComponentClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(typeof(bool)), DataComponentNameHandler.ClearBeforeFillVariableName));
            CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(typeof(bool)), DataComponentNameHandler.ClearBeforeFillPropertyName, MemberAttributes.Public | MemberAttributes.Final);

            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.ClearBeforeFillVariableName)));
            property.SetStatements.Add(CodeGenHelper.Assign(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.ClearBeforeFillVariableName), CodeGenHelper.Argument("value")));
            dataComponentClass.Members.Add(property);
        }
 internal void AddPrivateVars(CodeTypeDeclaration dataSourceClass)
 {
     if (this.tables != null)
     {
         foreach (DesignTable table in this.tables)
         {
             string generatorTableClassName = table.GeneratorTableClassName;
             string generatorTableVarName   = table.GeneratorTableVarName;
             dataSourceClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.Type(generatorTableClassName), generatorTableVarName));
         }
     }
 }
        private void AddSchemaSerializationModeMembers(CodeTypeDeclaration dataSourceClass)
        {
            CodeMemberField field = CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(typeof(SchemaSerializationMode)), "_schemaSerializationMode", CodeGenHelper.Field(CodeGenHelper.GlobalTypeExpr(typeof(SchemaSerializationMode)), this.dataSource.SchemaSerializationMode.ToString()));

            dataSourceClass.Members.Add(field);
            CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(typeof(SchemaSerializationMode)), "SchemaSerializationMode", MemberAttributes.Public | MemberAttributes.Override);

            property.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(BrowsableAttribute).FullName, CodeGenHelper.Primitive(true)));
            property.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(DesignerSerializationVisibilityAttribute).FullName, CodeGenHelper.Field(CodeGenHelper.GlobalTypeExpr(typeof(DesignerSerializationVisibility)), "Visible")));
            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), "_schemaSerializationMode")));
            property.SetStatements.Add(CodeGenHelper.Assign(CodeGenHelper.Field(CodeGenHelper.This(), "_schemaSerializationMode"), CodeGenHelper.Argument("value")));
            dataSourceClass.Members.Add(property);
        }
 internal void AddPrivateVariables(CodeTypeDeclaration dataTableClass)
 {
     if (dataTableClass == null)
     {
         throw new InternalException("Table CodeTypeDeclaration should not be null.");
     }
     if (this.columns != null)
     {
         foreach (DesignColumn column in this.columns)
         {
             dataTableClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(typeof(DataColumn)), column.GeneratorColumnVarNameInTable));
         }
     }
 }
 internal void AddPrivateVars(CodeTypeDeclaration dataSourceClass)
 {
     if (dataSourceClass == null)
     {
         throw new InternalException("DataSource CodeTypeDeclaration should not be null.");
     }
     if (this.relations != null)
     {
         foreach (DesignRelation relation in this.relations)
         {
             if (relation.DataRelation != null)
             {
                 string generatorRelationVarName = relation.GeneratorRelationVarName;
                 dataSourceClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(typeof(DataRelation)), generatorRelationVarName));
             }
         }
     }
 }
        private void AddCommandCollectionMembers(CodeTypeDeclaration dataComponentClass, bool isFunctionsDataComponent)
        {
            Type type = null;

            if (isFunctionsDataComponent)
            {
                type = typeof(IDbCommand);
            }
            else
            {
                type = this.providerFactory.CreateCommand().GetType();
            }
            dataComponentClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(type, 1), DataComponentNameHandler.SelectCmdCollectionVariableName));
            CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(type, 1), DataComponentNameHandler.SelectCmdCollectionPropertyName, MemberAttributes.Family | MemberAttributes.Final);

            property.GetStatements.Add(CodeGenHelper.If(CodeGenHelper.IdEQ(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionVariableName), CodeGenHelper.Primitive(null)), new CodeStatement[] { CodeGenHelper.Stm(CodeGenHelper.MethodCall(CodeGenHelper.This(), DataComponentNameHandler.InitCmdCollection, new CodeExpression[0])) }));
            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionVariableName)));
            dataComponentClass.Members.Add(property);
        }
        private CodeTypeDeclaration GenerateRow(DesignTable table)
        {
            if (table == null)
            {
                throw new InternalException("DesignTable should not be null.");
            }
            string              generatorRowClassName   = table.GeneratorRowClassName;
            string              generatorTableClassName = table.GeneratorTableClassName;
            string              generatorTableVarName   = table.GeneratorTableVarName;
            TypedColumnHandler  columnHandler           = this.codeGenerator.TableHandler.GetColumnHandler(table.Name);
            CodeTypeDeclaration rowClass = CodeGenHelper.Class(generatorRowClassName, true, TypeAttributes.Public);

            rowClass.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(DataRow)));
            rowClass.Comments.Add(CodeGenHelper.Comment("Represents strongly named DataRow class.", true));
            rowClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.Type(generatorTableClassName), generatorTableVarName));
            rowClass.Members.Add(this.RowConstructor(generatorTableClassName, generatorTableVarName));
            columnHandler.AddRowColumnProperties(rowClass);
            columnHandler.AddRowGetRelatedRowsMethods(rowClass);
            return(rowClass);
        }
        private void AddAdapterMembers(CodeTypeDeclaration dataComponentClass)
        {
            Type            type  = this.providerFactory.CreateDataAdapter().GetType();
            CodeMemberField field = CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(type), DataComponentNameHandler.AdapterVariableName);

            field.UserData.Add("WithEvents", true);
            dataComponentClass.Members.Add(field);
            CodeMemberProperty property = null;

            if (this.generateHierarchicalUpdate)
            {
                property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(type), DataComponentNameHandler.AdapterPropertyName, MemberAttributes.FamilyOrAssembly | MemberAttributes.Final);
            }
            else
            {
                property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(type), DataComponentNameHandler.AdapterPropertyName, MemberAttributes.Private | MemberAttributes.Final);
            }
            property.GetStatements.Add(CodeGenHelper.If(CodeGenHelper.IdEQ(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.AdapterVariableName), CodeGenHelper.Primitive(null)), new CodeStatement[] { CodeGenHelper.Stm(CodeGenHelper.MethodCall(CodeGenHelper.This(), DataComponentNameHandler.InitAdapter, new CodeExpression[0])) }));
            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.AdapterVariableName)));
            dataComponentClass.Members.Add(property);
        }
        private void AddConnectionMembers(CodeTypeDeclaration dataComponentClass)
        {
            Type             type     = this.providerFactory.CreateConnection().GetType();
            MemberAttributes modifier = ((DesignConnection)this.designTable.Connection).Modifier;

            dataComponentClass.Members.Add(CodeGenHelper.FieldDecl(CodeGenHelper.GlobalType(type), DataComponentNameHandler.DefaultConnectionVariableName));
            CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.GlobalType(type), DataComponentNameHandler.DefaultConnectionPropertyName, modifier | MemberAttributes.Final);

            property.GetStatements.Add(CodeGenHelper.If(CodeGenHelper.IdEQ(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.DefaultConnectionVariableName), CodeGenHelper.Primitive(null)), new CodeStatement[] { CodeGenHelper.Stm(CodeGenHelper.MethodCall(CodeGenHelper.This(), DataComponentNameHandler.InitConnection, new CodeExpression[0])) }));
            property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.DefaultConnectionVariableName)));
            property.SetStatements.Add(CodeGenHelper.Assign(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.DefaultConnectionVariableName), CodeGenHelper.Argument("value")));
            property.SetStatements.Add(CodeGenHelper.If(CodeGenHelper.IdNotEQ(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "InsertCommand"), CodeGenHelper.Primitive(null)), CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "InsertCommand"), "Connection"), CodeGenHelper.Argument("value"))));
            property.SetStatements.Add(CodeGenHelper.If(CodeGenHelper.IdNotEQ(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "DeleteCommand"), CodeGenHelper.Primitive(null)), CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "DeleteCommand"), "Connection"), CodeGenHelper.Argument("value"))));
            property.SetStatements.Add(CodeGenHelper.If(CodeGenHelper.IdNotEQ(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "UpdateCommand"), CodeGenHelper.Primitive(null)), CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "UpdateCommand"), "Connection"), CodeGenHelper.Argument("value"))));
            int            count          = this.designTable.Sources.Count;
            CodeStatement  initStmt       = CodeGenHelper.VariableDecl(CodeGenHelper.GlobalType(typeof(int)), "i", CodeGenHelper.Primitive(0));
            CodeExpression testExpression = CodeGenHelper.Less(CodeGenHelper.Variable("i"), CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), "Length"));
            CodeStatement  incrementStmt  = CodeGenHelper.Assign(CodeGenHelper.Variable("i"), CodeGenHelper.BinOperator(CodeGenHelper.Variable("i"), CodeBinaryOperatorType.Add, CodeGenHelper.Primitive(1)));
            CodeExpression left           = CodeGenHelper.Property(CodeGenHelper.Cast(CodeGenHelper.GlobalType(this.providerFactory.CreateCommand().GetType()), CodeGenHelper.Indexer(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), CodeGenHelper.Variable("i"))), "Connection");
            CodeStatement  statement3     = CodeGenHelper.If(CodeGenHelper.IdNotEQ(CodeGenHelper.Indexer(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), CodeGenHelper.Variable("i")), CodeGenHelper.Primitive(null)), CodeGenHelper.Assign(left, CodeGenHelper.Argument("value")));

            property.SetStatements.Add(CodeGenHelper.ForLoop(initStmt, testExpression, incrementStmt, new CodeStatement[] { statement3 }));
            dataComponentClass.Members.Add(property);
        }
        internal void AddRowColumnProperties(CodeTypeDeclaration rowClass)
        {
            bool   flag = false;
            string generatorRowClassName = this.codeGenerator.TableHandler.Tables[this.table.TableName].GeneratorRowClassName;
            string generatorTableVarName = this.codeGenerator.TableHandler.Tables[this.table.TableName].GeneratorTableVarName;

            foreach (DesignColumn column in this.columns)
            {
                CodeExpression     expression;
                CodeExpression     expression2;
                DataColumn         dataColumn = column.DataColumn;
                Type               dataType   = dataColumn.DataType;
                string             generatorColumnPropNameInRow   = column.GeneratorColumnPropNameInRow;
                string             generatorColumnPropNameInTable = column.GeneratorColumnPropNameInTable;
                GenericNameHandler handler  = new GenericNameHandler(new string[] { generatorColumnPropNameInRow }, this.codeGenerator.CodeProvider);
                CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.Type(dataType), generatorColumnPropNameInRow, MemberAttributes.Public | MemberAttributes.Final);
                CodeStatement      tryStmnt = CodeGenHelper.Return(CodeGenHelper.Cast(CodeGenHelper.GlobalType(dataType), CodeGenHelper.Indexer(CodeGenHelper.This(), CodeGenHelper.Property(CodeGenHelper.Field(CodeGenHelper.This(), generatorTableVarName), generatorColumnPropNameInTable))));
                if (!dataColumn.AllowDBNull)
                {
                    goto Label_0440;
                }
                string str5 = (string)dataColumn.ExtendedProperties["nullValue"];
                switch (str5)
                {
                case null:
                case "_throw":
                    tryStmnt = CodeGenHelper.Try(tryStmnt, CodeGenHelper.Catch(CodeGenHelper.GlobalType(typeof(InvalidCastException)), handler.AddNameToList("e"), CodeGenHelper.Throw(CodeGenHelper.GlobalType(typeof(StrongTypingException)), System.Design.SR.GetString("CG_ColumnIsDBNull", new object[] { dataColumn.ColumnName, this.table.TableName }), handler.GetNameFromList("e"))));
                    goto Label_0440;

                default:
                {
                    expression = null;
                    switch (str5)
                    {
                    case "_null":
                        if (dataColumn.DataType.IsSubclassOf(typeof(System.ValueType)))
                        {
                            this.codeGenerator.ProblemList.Add(new DSGeneratorProblem(System.Design.SR.GetString("CG_TypeCantBeNull", new object[] { dataColumn.ColumnName, dataColumn.DataType.Name }), ProblemSeverity.NonFatalError, column));
                            continue;
                        }
                        expression2 = CodeGenHelper.Primitive(null);
                        goto Label_03AE;

                    case "_empty":
                        if (dataColumn.DataType == typeof(string))
                        {
                            expression2 = CodeGenHelper.Property(CodeGenHelper.TypeExpr(CodeGenHelper.GlobalType(dataColumn.DataType)), "Empty");
                        }
                        else
                        {
                            expression2 = CodeGenHelper.Field(CodeGenHelper.TypeExpr(CodeGenHelper.Type(generatorRowClassName)), generatorColumnPropNameInRow + "_nullValue");
                            ConstructorInfo constructor = dataColumn.DataType.GetConstructor(new Type[] { typeof(string) });
                            if (constructor == null)
                            {
                                this.codeGenerator.ProblemList.Add(new DSGeneratorProblem(System.Design.SR.GetString("CG_NoCtor0", new object[] { dataColumn.ColumnName, dataColumn.DataType.Name }), ProblemSeverity.NonFatalError, column));
                                continue;
                            }
                            constructor.Invoke(new object[0]);
                            expression = CodeGenHelper.New(CodeGenHelper.Type(dataColumn.DataType), new CodeExpression[0]);
                        }
                        goto Label_03AE;
                    }
                    if (!flag)
                    {
                        this.table.NewRow();
                        flag = true;
                    }
                    object             valueObj = this.codeGenerator.RowHandler.RowGenerator.ConvertXmlToObject.Invoke(dataColumn, new object[] { str5 });
                    DSGeneratorProblem problem  = CodeGenHelper.GenerateValueExprAndFieldInit(column, valueObj, str5, generatorRowClassName, generatorColumnPropNameInRow + "_nullValue", out expression2, out expression);
                    if (problem != null)
                    {
                        this.codeGenerator.ProblemList.Add(problem);
                        continue;
                    }
                    break;
                }
                }
                Label_03AE :;
                tryStmnt = CodeGenHelper.If(CodeGenHelper.MethodCall(CodeGenHelper.This(), "Is" + generatorColumnPropNameInRow + "Null"), new CodeStatement[] { CodeGenHelper.Return(expression2) }, new CodeStatement[] { tryStmnt });
                if (expression != null)
                {
                    CodeMemberField field = CodeGenHelper.FieldDecl(CodeGenHelper.Type(dataColumn.DataType.FullName), generatorColumnPropNameInRow + "_nullValue");
                    field.Attributes     = MemberAttributes.Private | MemberAttributes.Static;
                    field.InitExpression = expression;
                    rowClass.Members.Add(field);
                }
Label_0440:
                property.GetStatements.Add(tryStmnt);
                property.SetStatements.Add(CodeGenHelper.Assign(CodeGenHelper.Indexer(CodeGenHelper.This(), CodeGenHelper.Property(CodeGenHelper.Field(CodeGenHelper.This(), generatorTableVarName), generatorColumnPropNameInTable)), CodeGenHelper.Value()));
                rowClass.Members.Add(property);
                if (dataColumn.AllowDBNull)
                {
                    string           name   = MemberNameValidator.GenerateIdName("Is" + generatorColumnPropNameInRow + "Null", this.codeGenerator.CodeProvider, false);
                    CodeMemberMethod method = CodeGenHelper.MethodDecl(CodeGenHelper.GlobalType(typeof(bool)), name, MemberAttributes.Public | MemberAttributes.Final);
                    method.Statements.Add(CodeGenHelper.Return(CodeGenHelper.MethodCall(CodeGenHelper.This(), "IsNull", CodeGenHelper.Property(CodeGenHelper.Field(CodeGenHelper.This(), generatorTableVarName), generatorColumnPropNameInTable))));
                    rowClass.Members.Add(method);
                    name = MemberNameValidator.GenerateIdName("Set" + generatorColumnPropNameInRow + "Null", this.codeGenerator.CodeProvider, false);
                    CodeMemberMethod method2 = CodeGenHelper.MethodDecl(CodeGenHelper.GlobalType(typeof(void)), name, MemberAttributes.Public | MemberAttributes.Final);
                    method2.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Indexer(CodeGenHelper.This(), CodeGenHelper.Property(CodeGenHelper.Field(CodeGenHelper.This(), generatorTableVarName), generatorColumnPropNameInTable)), CodeGenHelper.Field(CodeGenHelper.GlobalTypeExpr(typeof(Convert)), "DBNull")));
                    rowClass.Members.Add(method2);
                }
            }
        }
        private void InitClassAndInitVarsMethods(CodeTypeDeclaration tableClass, out CodeMemberMethod tableInitClass, out CodeMemberMethod tableInitVars)
        {
            DataTable dataTable = this.designTable.DataTable;

            tableInitClass = CodeGenHelper.MethodDecl(CodeGenHelper.GlobalType(typeof(void)), "InitClass", MemberAttributes.Private);
            tableInitVars  = CodeGenHelper.MethodDecl(CodeGenHelper.GlobalType(typeof(void)), "InitVars", MemberAttributes.Assembly | MemberAttributes.Final);
            for (int i = 0; i < dataTable.Columns.Count; i++)
            {
                DataColumn     column = dataTable.Columns[i];
                string         generatorColumnVarNameInTable = this.codeGenerator.TableHandler.Tables[dataTable.TableName].DesignColumns[column.ColumnName].GeneratorColumnVarNameInTable;
                CodeExpression left = CodeGenHelper.Field(CodeGenHelper.This(), generatorColumnVarNameInTable);
                string         str2 = "Element";
                if (column.ColumnMapping == MappingType.SimpleContent)
                {
                    str2 = "SimpleContent";
                }
                else if (column.ColumnMapping == MappingType.Attribute)
                {
                    str2 = "Attribute";
                }
                else if (column.ColumnMapping == MappingType.Hidden)
                {
                    str2 = "Hidden";
                }
                tableInitClass.Statements.Add(CodeGenHelper.Assign(left, CodeGenHelper.New(CodeGenHelper.GlobalType(typeof(DataColumn)), new CodeExpression[] { CodeGenHelper.Str(column.ColumnName), CodeGenHelper.TypeOf(CodeGenHelper.GlobalType(column.DataType)), CodeGenHelper.Primitive(null), CodeGenHelper.Field(CodeGenHelper.GlobalTypeExpr(typeof(MappingType)), str2) })));
                ExtendedPropertiesHandler.CodeGenerator = this.codeGenerator;
                ExtendedPropertiesHandler.AddExtendedProperties(this.designTable.DesignColumns[column.ColumnName], left, tableInitClass.Statements, column.ExtendedProperties);
                tableInitClass.Statements.Add(CodeGenHelper.MethodCall(CodeGenHelper.Property(CodeGenHelper.Base(), "Columns"), "Add", CodeGenHelper.Field(CodeGenHelper.This(), generatorColumnVarNameInTable)));
            }
            for (int j = 0; j < dataTable.Constraints.Count; j++)
            {
                if (dataTable.Constraints[j] is UniqueConstraint)
                {
                    UniqueConstraint constraint   = (UniqueConstraint)dataTable.Constraints[j];
                    DataColumn[]     columns      = constraint.Columns;
                    CodeExpression[] initializers = new CodeExpression[columns.Length];
                    for (int m = 0; m < columns.Length; m++)
                    {
                        initializers[m] = CodeGenHelper.Field(CodeGenHelper.This(), this.codeGenerator.TableHandler.Tables[columns[m].Table.TableName].DesignColumns[columns[m].ColumnName].GeneratorColumnVarNameInTable);
                    }
                    tableInitClass.Statements.Add(CodeGenHelper.MethodCall(CodeGenHelper.Property(CodeGenHelper.This(), "Constraints"), "Add", CodeGenHelper.New(CodeGenHelper.GlobalType(typeof(UniqueConstraint)), new CodeExpression[] { CodeGenHelper.Str(constraint.ConstraintName), new CodeArrayCreateExpression(CodeGenHelper.GlobalType(typeof(DataColumn)), initializers), CodeGenHelper.Primitive(constraint.IsPrimaryKey) })));
                }
            }
            for (int k = 0; k < dataTable.Columns.Count; k++)
            {
                DataColumn     component   = dataTable.Columns[k];
                string         str3        = this.codeGenerator.TableHandler.Tables[dataTable.TableName].DesignColumns[component.ColumnName].GeneratorColumnVarNameInTable;
                CodeExpression expression2 = CodeGenHelper.Field(CodeGenHelper.This(), str3);
                tableInitVars.Statements.Add(CodeGenHelper.Assign(expression2, CodeGenHelper.Indexer(CodeGenHelper.Property(CodeGenHelper.Base(), "Columns"), CodeGenHelper.Str(component.ColumnName))));
                if (component.AutoIncrement)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "AutoIncrement"), CodeGenHelper.Primitive(true)));
                }
                if (component.AutoIncrementSeed != 0L)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "AutoIncrementSeed"), CodeGenHelper.Primitive(component.AutoIncrementSeed)));
                }
                if (component.AutoIncrementStep != 1L)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "AutoIncrementStep"), CodeGenHelper.Primitive(component.AutoIncrementStep)));
                }
                if (!component.AllowDBNull)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "AllowDBNull"), CodeGenHelper.Primitive(false)));
                }
                if (component.ReadOnly)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "ReadOnly"), CodeGenHelper.Primitive(true)));
                }
                if (component.Unique)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "Unique"), CodeGenHelper.Primitive(true)));
                }
                if (!StringUtil.Empty(component.Prefix))
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "Prefix"), CodeGenHelper.Str(component.Prefix)));
                }
                if (columnNamespaceProperty.ShouldSerializeValue(component))
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "Namespace"), CodeGenHelper.Str(component.Namespace)));
                }
                if (component.Caption != component.ColumnName)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "Caption"), CodeGenHelper.Str(component.Caption)));
                }
                if (component.DefaultValue != DBNull.Value)
                {
                    CodeExpression     valueExpr    = null;
                    CodeExpression     fieldInit    = null;
                    DesignColumn       designColumn = this.codeGenerator.TableHandler.Tables[dataTable.TableName].DesignColumns[component.ColumnName];
                    DSGeneratorProblem problem      = CodeGenHelper.GenerateValueExprAndFieldInit(designColumn, component.DefaultValue, component.DefaultValue, this.designTable.GeneratorTableClassName, str3 + "_defaultValue", out valueExpr, out fieldInit);
                    if (problem != null)
                    {
                        this.codeGenerator.ProblemList.Add(problem);
                    }
                    else
                    {
                        if (fieldInit != null)
                        {
                            CodeMemberField field = CodeGenHelper.FieldDecl(CodeGenHelper.Type(component.DataType.FullName), str3 + "_defaultValue");
                            field.Attributes     = MemberAttributes.Private | MemberAttributes.Static;
                            field.InitExpression = fieldInit;
                            tableClass.Members.Add(field);
                        }
                        CodeCastExpression right = new CodeCastExpression(component.DataType, valueExpr);
                        right.UserData.Add("CastIsBoxing", true);
                        tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "DefaultValue"), right));
                    }
                }
                if (component.MaxLength != -1)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "MaxLength"), CodeGenHelper.Primitive(component.MaxLength)));
                }
                if (component.DateTimeMode != DataSetDateTime.UnspecifiedLocal)
                {
                    tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(expression2, "DateTimeMode"), CodeGenHelper.Field(CodeGenHelper.GlobalTypeExpr(typeof(DataSetDateTime)), component.DateTimeMode.ToString())));
                }
            }
            if (caseSensitiveProperty.ShouldSerializeValue(dataTable))
            {
                tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.This(), "CaseSensitive"), CodeGenHelper.Primitive(dataTable.CaseSensitive)));
            }
            if ((dataTable.Locale != null) && localeProperty.ShouldSerializeValue(dataTable))
            {
                tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.This(), "Locale"), CodeGenHelper.New(CodeGenHelper.GlobalType(typeof(CultureInfo)), new CodeExpression[] { CodeGenHelper.Str(dataTable.Locale.ToString()) })));
            }
            if (!StringUtil.Empty(dataTable.Prefix))
            {
                tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.This(), "Prefix"), CodeGenHelper.Str(dataTable.Prefix)));
            }
            if (namespaceProperty.ShouldSerializeValue(dataTable))
            {
                tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.This(), "Namespace"), CodeGenHelper.Str(dataTable.Namespace)));
            }
            if (dataTable.MinimumCapacity != 50)
            {
                tableInitClass.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.This(), "MinimumCapacity"), CodeGenHelper.Primitive(dataTable.MinimumCapacity)));
            }
            ExtendedPropertiesHandler.CodeGenerator = this.codeGenerator;
            ExtendedPropertiesHandler.AddExtendedProperties(this.designTable, CodeGenHelper.This(), tableInitClass.Statements, dataTable.ExtendedProperties);
        }