internal TypedColumnHandler(DesignTable designTable, TypedDataSourceCodeGenerator codeGenerator)
 {
     this.codeGenerator = codeGenerator;
     this.table = designTable.DataTable;
     this.designTable = designTable;
     this.columns = designTable.DesignColumns;
 }
 internal CodeTypeDeclaration GenerateDataComponent(DesignTable designTable, bool isFunctionsComponent, bool generateHierarchicalUpdate)
 {
     CodeTypeDeclaration dataComponentClass = CodeGenHelper.Class(designTable.GeneratorDataComponentClassName, true, designTable.DataAccessorModifier);
     dataComponentClass.BaseTypes.Add(CodeGenHelper.GlobalType(designTable.BaseClass));
     dataComponentClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.DesignerCategoryAttribute", CodeGenHelper.Str("code")));
     dataComponentClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.ToolboxItem", CodeGenHelper.Primitive(true)));
     dataComponentClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.DataObjectAttribute", CodeGenHelper.Primitive(true)));
     dataComponentClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.ComponentModel.DesignerAttribute", CodeGenHelper.Str(adapterDesigner + ", Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")));
     dataComponentClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(HelpKeywordAttribute).FullName, CodeGenHelper.Str("vs.data.TableAdapter")));
     if (designTable.WebServiceAttribute)
     {
         CodeAttributeDeclaration declaration2 = new CodeAttributeDeclaration("System.Web.Services.WebService");
         declaration2.Arguments.Add(new CodeAttributeArgument("Namespace", CodeGenHelper.Str(designTable.WebServiceNamespace)));
         declaration2.Arguments.Add(new CodeAttributeArgument("Description", CodeGenHelper.Str(designTable.WebServiceDescription)));
         dataComponentClass.CustomAttributes.Add(declaration2);
     }
     dataComponentClass.Comments.Add(CodeGenHelper.Comment("Represents the connection and commands used to retrieve and save data.", true));
     new DataComponentMethodGenerator(this.dataSourceGenerator, designTable, generateHierarchicalUpdate).AddMethods(dataComponentClass, isFunctionsComponent);
     CodeGenerator.ValidateIdentifiers(dataComponentClass);
     QueryHandler handler = new QueryHandler(this.dataSourceGenerator, designTable);
     if (isFunctionsComponent)
     {
         handler.AddFunctionsToDataComponent(dataComponentClass, true);
         return dataComponentClass;
     }
     handler.AddQueriesToDataComponent(dataComponentClass);
     return dataComponentClass;
 }
 private CodeTypeDeclaration GenerateTable(DesignTable designTable, CodeTypeDeclaration dataSourceClass)
 {
     string generatorTableClassName = designTable.GeneratorTableClassName;
     TypedColumnHandler columnHandler = this.codeGenerator.TableHandler.GetColumnHandler(designTable.Name);
     CodeTypeDeclaration dataTableClass = CodeGenHelper.Class(generatorTableClassName, true, TypeAttributes.Public);
     if ((this.codeGenerator.GenerateOptions & System.Data.Design.TypedDataSetGenerator.GenerateOption.LinqOverTypedDatasets) == System.Data.Design.TypedDataSetGenerator.GenerateOption.LinqOverTypedDatasets)
     {
         dataTableClass.BaseTypes.Add(CodeGenHelper.GlobalGenericType(LINQOverTDSTableBaseClass, CodeGenHelper.Type(designTable.GeneratorRowClassName)));
     }
     else
     {
         dataTableClass.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(DataTable)));
         dataTableClass.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(IEnumerable)));
     }
     dataTableClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl("System.Serializable"));
     dataTableClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(XmlSchemaProviderAttribute).FullName, CodeGenHelper.Primitive("GetTypedTableSchema")));
     dataTableClass.Comments.Add(CodeGenHelper.Comment("Represents the strongly named DataTable class.", true));
     columnHandler.AddPrivateVariables(dataTableClass);
     columnHandler.AddTableColumnProperties(dataTableClass);
     dataTableClass.Members.Add(this.CountProperty());
     if (this.codeGenerator.CodeProvider.Supports(GeneratorSupport.DeclareIndexerProperties))
     {
         dataTableClass.Members.Add(this.IndexProperty(designTable));
     }
     if (this.codeGenerator.CodeProvider.Supports(GeneratorSupport.DeclareEvents) && this.codeGenerator.CodeProvider.Supports(GeneratorSupport.DeclareDelegates))
     {
         this.codeGenerator.RowHandler.AddTypedRowEvents(dataTableClass, designTable.Name);
     }
     new TableMethodGenerator(this.codeGenerator, designTable).AddMethods(dataTableClass);
     return dataTableClass;
 }
 internal QueryHandler(CodeDomProvider codeProvider, DesignTable designTable)
 {
     this.codeGenerator = new TypedDataSourceCodeGenerator();
     this.codeGenerator.CodeProvider = codeProvider;
     this.designTable = designTable;
     this.languageSupportsNullables = this.codeGenerator.CodeProvider.Supports(GeneratorSupport.GenericTypeReference);
 }
 internal void GenerateMemberNames(DesignTable designTable, CodeDomProvider codeProvider, bool languageCaseInsensitive, ArrayList problemList)
 {
     this.languageCaseInsensitive = languageCaseInsensitive;
     this.validator = new MemberNameValidator(null, codeProvider, this.languageCaseInsensitive);
     this.AddReservedNames();
     this.ProcessMemberNames(designTable);
 }
 internal void GenerateMemberNames(DesignDataSource dataSource, ArrayList problemList)
 {
     if ((dataSource == null) || (codeProvider == null))
     {
         throw new InternalException("DesignDataSource or/and CodeDomProvider parameters are null.");
     }
     InitLookupIdentifiers();
     this.dataSourceHandler = new DataSourceNameHandler();
     this.dataSourceHandler.GenerateMemberNames(dataSource, codeProvider, this.languageCaseInsensitive, problemList);
     foreach (DesignTable table in dataSource.DesignTables)
     {
         new DataTableNameHandler().GenerateMemberNames(table, codeProvider, this.languageCaseInsensitive, problemList);
         new DataComponentNameHandler().GenerateMemberNames(table, codeProvider, this.languageCaseInsensitive, problemList);
     }
     if ((dataSource.Sources != null) && (dataSource.Sources.Count > 0))
     {
         DesignTable designTable = new DesignTable {
             TableType = TableType.RadTable,
             DataAccessorName = dataSource.FunctionsComponentName,
             UserDataComponentName = dataSource.UserFunctionsComponentName,
             GeneratorDataComponentClassName = dataSource.GeneratorFunctionsComponentClassName
         };
         foreach (Source source in dataSource.Sources)
         {
             designTable.Sources.Add(source);
         }
         new DataComponentNameHandler { GlobalSources = true }.GenerateMemberNames(designTable, codeProvider, this.languageCaseInsensitive, problemList);
         dataSource.GeneratorFunctionsComponentClassName = designTable.GeneratorDataComponentClassName;
     }
 }
 private CodeMemberProperty IndexProperty(DesignTable designTable)
 {
     string generatorRowClassName = designTable.GeneratorRowClassName;
     CodeMemberProperty property = CodeGenHelper.PropertyDecl(CodeGenHelper.Type(generatorRowClassName), "Item", MemberAttributes.Public | MemberAttributes.Final);
     property.Parameters.Add(CodeGenHelper.ParameterDecl(CodeGenHelper.GlobalType(typeof(int)), "index"));
     property.GetStatements.Add(CodeGenHelper.Return(CodeGenHelper.Cast(CodeGenHelper.Type(generatorRowClassName), CodeGenHelper.Indexer(CodeGenHelper.Property(CodeGenHelper.This(), "Rows"), CodeGenHelper.Argument("index")))));
     return property;
 }
 internal DataComponentMethodGenerator(TypedDataSourceCodeGenerator codeGenerator, DesignTable designTable, bool generateHierarchicalUpdate)
 {
     this.generateHierarchicalUpdate = generateHierarchicalUpdate;
     this.codeGenerator = codeGenerator;
     this.designTable = designTable;
     if (designTable.Connection != null)
     {
         this.providerFactory = ProviderManager.GetFactory(designTable.Connection.Provider);
     }
 }
 internal void ProcessClassName(DesignTable table)
 {
     if (!StringUtil.EqualValue(table.DataAccessorName, table.UserDataComponentName, this.languageCaseInsensitive) || StringUtil.Empty(table.GeneratorDataComponentClassName))
     {
         table.GeneratorDataComponentClassName = this.validator.GenerateIdName(table.DataAccessorName);
     }
     else
     {
         table.GeneratorDataComponentClassName = this.validator.GenerateIdName(table.GeneratorDataComponentClassName);
     }
 }
 public DesignColumnCollection(DesignTable designTable) : base(designTable)
 {
     this.designTable = designTable;
     if ((designTable != null) && (designTable.DataTable != null))
     {
         foreach (DataColumn column in designTable.DataTable.Columns)
         {
             this.Add(new DesignColumn(column));
         }
     }
     this.table = designTable;
 }
 private void ProcessMemberNames(DesignTable designTable)
 {
     this.ProcessClassName(designTable);
     if (!this.GlobalSources && (designTable.MainSource != null))
     {
         this.ProcessSourceName((DbSource) designTable.MainSource);
     }
     if (designTable.Sources != null)
     {
         foreach (Source source in designTable.Sources)
         {
             this.ProcessSourceName((DbSource) source);
         }
     }
 }
 private DesignRelation FindCorrespondingDesignRelation(DesignTable designTable, DataRelation relation)
 {
     DesignDataSource owner = designTable.Owner;
     if (owner == null)
     {
         throw new InternalException("Unable to find DataSource for table.");
     }
     foreach (DesignRelation relation2 in owner.DesignRelations)
     {
         if (((relation2.DataRelation != null) && StringUtil.EqualValue(relation2.DataRelation.ChildTable.TableName, relation.ChildTable.TableName)) && (StringUtil.EqualValue(relation2.DataRelation.ParentTable.TableName, relation.ParentTable.TableName) && StringUtil.EqualValue(relation2.Name, relation.RelationName)))
         {
             return relation2;
         }
     }
     return null;
 }
 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 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;
 }
 public bool Contains(DesignTable table)
 {
     return base.List.Contains(table);
 }
 public int IndexOf(DesignTable table)
 {
     return base.List.IndexOf(table);
 }
 public void Remove(DesignTable table)
 {
     base.List.Remove(table);
 }
 public void Add(DesignTable designTable)
 {
     base.List.Add(designTable);
 }
 internal CodeGenPropertyCache(DesignTable designTable)
 {
     this.designTable = designTable;
 }
 internal TableMethodGenerator(TypedDataSourceCodeGenerator codeGenerator, DesignTable designTable)
 {
     this.codeGenerator = codeGenerator;
     this.designTable = designTable;
 }
 private CodeTypeDelegate GenerateTypedRowEventHandler(DesignTable table)
 {
     if (table == null)
     {
         throw new InternalException("DesignTable should not be null.");
     }
     string generatorRowClassName = table.GeneratorRowClassName;
     CodeTypeDelegate codeTypeDelegate = new CodeTypeDelegate(table.GeneratorRowEvHandlerName);
     CodeTypeDelegate typeAttributes = codeTypeDelegate;
     typeAttributes.TypeAttributes = typeAttributes.TypeAttributes | TypeAttributes.Public;
     codeTypeDelegate.Parameters.Add(CodeGenHelper.ParameterDecl(CodeGenHelper.GlobalType(typeof(object)), "sender"));
     codeTypeDelegate.Parameters.Add(CodeGenHelper.ParameterDecl(CodeGenHelper.Type(table.GeneratorRowEvArgName), "e"));
     codeTypeDelegate.CustomAttributes.Add(CodeGenHelper.GeneratedCodeAttributeDecl());
     return codeTypeDelegate;
 }
 internal void ProcessTableRelatedNames(DesignTable table)
 {
     bool usesAnnotations = false;
     bool flag2 = false;
     bool flag3 = !StringUtil.EqualValue(table.Name, table.UserTableName, this.languageCaseInsensitive);
     string name = this.TablePropertyName(table.DataTable, out usesAnnotations);
     string str2 = this.PlainTablePropertyName(table.DataTable, out usesAnnotations);
     if (usesAnnotations)
     {
         table.GeneratorTablePropName = str2;
     }
     else
     {
         if (flag3 || StringUtil.Empty(table.GeneratorTablePropName))
         {
             table.GeneratorTablePropName = this.validator.GenerateIdName(name);
         }
         else
         {
             table.GeneratorTablePropName = this.validator.GenerateIdName(table.GeneratorTablePropName);
         }
         if (!StringUtil.EqualValue(this.validator.GenerateIdName(name), table.GeneratorTablePropName))
         {
             table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_TABLEPROPNAME);
             flag2 = true;
         }
     }
     string str3 = this.TableVariableName(table.DataTable, out usesAnnotations);
     string str4 = this.PlainTableVariableName(table.DataTable, out usesAnnotations);
     if (usesAnnotations)
     {
         table.GeneratorTableVarName = str4;
     }
     else
     {
         if (flag3 || StringUtil.Empty(table.GeneratorTableVarName))
         {
             table.GeneratorTableVarName = this.validator.GenerateIdName(str3);
         }
         else
         {
             table.GeneratorTableVarName = this.validator.GenerateIdName(table.GeneratorTableVarName);
         }
         if (!StringUtil.EqualValue(this.validator.GenerateIdName(str3), table.GeneratorTableVarName))
         {
             table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_TABLEVARNAME);
             flag2 = true;
         }
     }
     string str5 = this.TableClassName(table.DataTable, out usesAnnotations);
     string str6 = this.PlainTableClassName(table.DataTable, out usesAnnotations);
     if (usesAnnotations)
     {
         table.GeneratorTableClassName = str6;
     }
     else
     {
         if (flag3 || StringUtil.Empty(table.GeneratorTableClassName))
         {
             table.GeneratorTableClassName = this.validator.GenerateIdName(str5);
         }
         else
         {
             table.GeneratorTableClassName = this.validator.GenerateIdName(table.GeneratorTableClassName);
         }
         if (!StringUtil.EqualValue(this.validator.GenerateIdName(str5), table.GeneratorTableClassName))
         {
             table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_TABLECLASSNAME);
             flag2 = true;
         }
     }
     string str7 = this.RowClassName(table.DataTable, out usesAnnotations);
     string str8 = this.PlainRowClassName(table.DataTable, out usesAnnotations);
     if (usesAnnotations)
     {
         table.GeneratorRowClassName = str8;
     }
     else
     {
         if (flag3 || StringUtil.Empty(table.GeneratorRowClassName))
         {
             table.GeneratorRowClassName = this.validator.GenerateIdName(str7);
         }
         else
         {
             table.GeneratorRowClassName = this.validator.GenerateIdName(table.GeneratorRowClassName);
         }
         if (!StringUtil.EqualValue(this.validator.GenerateIdName(str7), table.GeneratorRowClassName))
         {
             table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWCLASSNAME);
             flag2 = true;
         }
     }
     string str9 = this.RowEventHandlerName(table.DataTable, out usesAnnotations);
     string str10 = this.PlainRowEventHandlerName(table.DataTable, out usesAnnotations);
     if (usesAnnotations)
     {
         table.GeneratorRowEvHandlerName = str10;
     }
     else
     {
         if (flag3 || StringUtil.Empty(table.GeneratorRowEvHandlerName))
         {
             table.GeneratorRowEvHandlerName = this.validator.GenerateIdName(str9);
         }
         else
         {
             table.GeneratorRowEvHandlerName = this.validator.GenerateIdName(table.GeneratorRowEvHandlerName);
         }
         if (!StringUtil.EqualValue(this.validator.GenerateIdName(str9), table.GeneratorRowEvHandlerName))
         {
             table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWEVHANDLERNAME);
             flag2 = true;
         }
     }
     string str11 = this.RowEventArgClassName(table.DataTable, out usesAnnotations);
     string str12 = this.PlainRowEventArgClassName(table.DataTable, out usesAnnotations);
     if (usesAnnotations)
     {
         table.GeneratorRowEvArgName = str12;
     }
     else
     {
         if (flag3 || StringUtil.Empty(table.GeneratorRowEvArgName))
         {
             table.GeneratorRowEvArgName = this.validator.GenerateIdName(str11);
         }
         else
         {
             table.GeneratorRowEvArgName = this.validator.GenerateIdName(table.GeneratorRowEvArgName);
         }
         if (!StringUtil.EqualValue(this.validator.GenerateIdName(str11), table.GeneratorRowEvArgName))
         {
             table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWEVARGNAME);
             flag2 = true;
         }
     }
     if (flag2)
     {
         table.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_USER_TABLENAME);
     }
 }
 private bool TableContainsExpressions(DesignTable designTable)
 {
     foreach (DataColumn column in designTable.DataTable.Columns)
     {
         if (column.Expression.Length > 0)
         {
             return true;
         }
     }
     return false;
 }
 private void ProcessMemberNames(DesignTable designTable)
 {
     if (designTable.DesignColumns != null)
     {
         foreach (DesignColumn column in designTable.DesignColumns)
         {
             this.ProcessColumnRelatedNames(column);
         }
     }
     DataRelationCollection childRelations = designTable.DataTable.ChildRelations;
     if (childRelations != null)
     {
         foreach (DataRelation relation in childRelations)
         {
             DesignRelation relation2 = this.FindCorrespondingDesignRelation(designTable, relation);
             this.ProcessChildRelationName(relation2);
         }
     }
     DataRelationCollection parentRelations = designTable.DataTable.ParentRelations;
     if (parentRelations != null)
     {
         foreach (DataRelation relation3 in parentRelations)
         {
             DesignRelation relation4 = this.FindCorrespondingDesignRelation(designTable, relation3);
             this.ProcessParentRelationName(relation4);
         }
     }
     this.ProcessEventNames(designTable);
 }
 internal void GenerateDataSource(DesignDataSource dtDataSource, CodeCompileUnit codeCompileUnit, CodeNamespace mainNamespace, string dataSetNamespace, System.Data.Design.TypedDataSetGenerator.GenerateOption generateOption)
 {
     this.designDataSource = dtDataSource;
     this.generateOption = generateOption;
     this.dataSetNamespace = dataSetNamespace;
     bool generateHierarchicalUpdate = ((generateOption & System.Data.Design.TypedDataSetGenerator.GenerateOption.HierarchicalUpdate) == System.Data.Design.TypedDataSetGenerator.GenerateOption.HierarchicalUpdate) && dtDataSource.EnableTableAdapterManager;
     this.AddUserData(codeCompileUnit);
     CodeTypeDeclaration declaration = this.CreateDataSourceDeclaration(dtDataSource);
     mainNamespace.Types.Add(declaration);
     bool flag2 = CodeGenHelper.SupportsMultipleNamespaces(this.codeProvider);
     CodeNamespace namespace2 = null;
     if (!this.GenerateSingleNamespace && flag2)
     {
         string name = this.CreateAdaptersNamespace(dtDataSource.GeneratorDataSetName);
         if (!StringUtil.Empty(mainNamespace.Name))
         {
             name = mainNamespace.Name + "." + name;
         }
         namespace2 = new CodeNamespace(name);
     }
     DataComponentGenerator generator = new DataComponentGenerator(this);
     bool flag3 = false;
     foreach (DesignTable table in dtDataSource.DesignTables)
     {
         if (table.TableType == TableType.RadTable)
         {
             flag3 = true;
             table.PropertyCache = new DesignTable.CodeGenPropertyCache(table);
             CodeTypeDeclaration declaration2 = generator.GenerateDataComponent(table, false, generateHierarchicalUpdate);
             if (this.GenerateSingleNamespace)
             {
                 mainNamespace.Types.Add(declaration2);
             }
             else if (flag2)
             {
                 namespace2.Types.Add(declaration2);
             }
             else
             {
                 declaration2.Name = declaration.Name + declaration2.Name;
                 mainNamespace.Types.Add(declaration2);
             }
         }
     }
     generateHierarchicalUpdate = generateHierarchicalUpdate && flag3;
     if ((dtDataSource.Sources != null) && (dtDataSource.Sources.Count > 0))
     {
         DesignTable designTable = new DesignTable {
             TableType = TableType.RadTable,
             MainSource = null,
             GeneratorDataComponentClassName = dtDataSource.GeneratorFunctionsComponentClassName
         };
         foreach (Source source in dtDataSource.Sources)
         {
             designTable.Sources.Add(source);
         }
         CodeTypeDeclaration declaration3 = generator.GenerateDataComponent(designTable, true, generateHierarchicalUpdate);
         if (this.GenerateSingleNamespace)
         {
             mainNamespace.Types.Add(declaration3);
         }
         else if (flag2)
         {
             namespace2.Types.Add(declaration3);
         }
         else
         {
             declaration3.Name = declaration.Name + declaration3.Name;
             mainNamespace.Types.Add(declaration3);
         }
     }
     if ((namespace2 != null) && (namespace2.Types.Count > 0))
     {
         codeCompileUnit.Namespaces.Add(namespace2);
     }
     if (generateHierarchicalUpdate)
     {
         CodeTypeDeclaration declaration4 = new TableAdapterManagerGenerator(this).GenerateAdapterManager(this.designDataSource, declaration);
         if (this.GenerateSingleNamespace)
         {
             mainNamespace.Types.Add(declaration4);
         }
         else if (flag2)
         {
             namespace2.Types.Add(declaration4);
         }
         else
         {
             declaration4.Name = declaration.Name + declaration4.Name;
             mainNamespace.Types.Add(declaration4);
         }
     }
 }
 public void SetDesignTableContent(string designTableContent)
 {
     DesignDataSource source = new DesignDataSource();
     StringReader textReader = new StringReader(designTableContent);
     source.ReadXmlSchema(textReader, null);
     if ((source.DesignTables == null) || (source.DesignTables.Count != 1))
     {
         throw new InternalException("Unexpected number of sources in deserialized DataSource.");
     }
     IEnumerator enumerator = source.DesignTables.GetEnumerator();
     enumerator.MoveNext();
     this.designTable = (DesignTable) enumerator.Current;
 }
 internal void ProcessEventNames(DesignTable designTable)
 {
     bool flag = false;
     bool flag2 = !StringUtil.EqualValue(designTable.Name, designTable.UserTableName, this.languageCaseInsensitive);
     string name = designTable.GeneratorRowClassName + "Changing";
     if (flag2 || StringUtil.Empty(designTable.GeneratorRowChangingName))
     {
         designTable.GeneratorRowChangingName = this.validator.GenerateIdName(name);
     }
     else
     {
         designTable.GeneratorRowChangingName = this.validator.GenerateIdName(designTable.GeneratorRowChangingName);
     }
     if (!StringUtil.EqualValue(this.validator.GenerateIdName(name), designTable.GeneratorRowChangingName))
     {
         designTable.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWCHANGINGNAME);
         flag = true;
     }
     string str2 = designTable.GeneratorRowClassName + "Changed";
     if (flag2 || StringUtil.Empty(designTable.GeneratorRowChangedName))
     {
         designTable.GeneratorRowChangedName = this.validator.GenerateIdName(str2);
     }
     else
     {
         designTable.GeneratorRowChangedName = this.validator.GenerateIdName(designTable.GeneratorRowChangedName);
     }
     if (!StringUtil.EqualValue(this.validator.GenerateIdName(str2), designTable.GeneratorRowChangedName))
     {
         designTable.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWCHANGEDNAME);
         flag = true;
     }
     string str3 = designTable.GeneratorRowClassName + "Deleting";
     if (flag2 || StringUtil.Empty(designTable.GeneratorRowDeletingName))
     {
         designTable.GeneratorRowDeletingName = this.validator.GenerateIdName(str3);
     }
     else
     {
         designTable.GeneratorRowDeletingName = this.validator.GenerateIdName(designTable.GeneratorRowDeletingName);
     }
     if (!StringUtil.EqualValue(this.validator.GenerateIdName(str3), designTable.GeneratorRowDeletingName))
     {
         designTable.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWDELETINGNAME);
         flag = true;
     }
     string str4 = designTable.GeneratorRowClassName + "Deleted";
     if (flag2 || StringUtil.Empty(designTable.GeneratorRowDeletedName))
     {
         designTable.GeneratorRowDeletedName = this.validator.GenerateIdName(str4);
     }
     else
     {
         designTable.GeneratorRowDeletedName = this.validator.GenerateIdName(designTable.GeneratorRowDeletedName);
     }
     if (!StringUtil.EqualValue(this.validator.GenerateIdName(str4), designTable.GeneratorRowDeletedName))
     {
         designTable.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_GENERATOR_ROWDELETEDNAME);
         flag = true;
     }
     if (flag && !designTable.NamingPropertyNames.Contains(DesignTable.EXTPROPNAME_USER_TABLENAME))
     {
         designTable.NamingPropertyNames.Add(DesignTable.EXTPROPNAME_USER_TABLENAME);
     }
 }