/// <summary> /// Method that gets called prior to calling <see cref="Render"/>. /// Use this method to initialize the properties to be used by the render process. /// You can access the project item attached to this generator by using the <see cref="ProjectItem"/> property. /// </summary> public override void PreRender() { base.PreRender(); var filePath = base.ProjectItem.FullPath; this._dataSet = new System.Data.DataSet(); this._dataSet.ReadXmlSchema(filePath); var xdoc = XDocument.Load(filePath); //get HierarchicalUpdate property var ns = xdoc.Root.Name.Namespace; var mspropNs = xdoc.Root.GetNamespaceOfPrefix("msprop"); var enableManagerString = xdoc.Root.Element(ns + "element").Attribute(mspropNs + "EnableTableAdapterManager").Value; var enableManager = Convert.ToBoolean(enableManagerString); _generateOption = enableManager ? System.Data.Design.TypedDataSetGenerator.GenerateOption.HierarchicalUpdate : System.Data.Design.TypedDataSetGenerator.GenerateOption.None; }
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); } } }