Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / TableAdapterManagerGenerator.cs / 3 / TableAdapterManagerGenerator.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All Rights Reserved.
// Information Contained Herein is Proprietary and Confidential.
//
//-----------------------------------------------------------------------------
namespace System.Data.Design {
using System.Diagnostics;
using System;
using System.IO;
using System.Data;
using System.CodeDom;
using System.Text;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Globalization;
using System.CodeDom.Compiler;
using System.Runtime.InteropServices;
///
/// This class is used to generate the TableAdapterManager in the Hierarchical Update feature
/// TypedDataSourceCodeGenerator will instanciate this class to generate TableAdapterManager related code.
///
internal sealed class TableAdapterManagerGenerator {
private TypedDataSourceCodeGenerator dataSourceGenerator = null;
private const string adapterDesigner = "Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerDesigner";
private const string helpKeyword = "vs.data.TableAdapterManager";
internal TableAdapterManagerGenerator(TypedDataSourceCodeGenerator codeGenerator) {
this.dataSourceGenerator = codeGenerator;
}
internal CodeTypeDeclaration GenerateAdapterManager(DesignDataSource dataSource, CodeTypeDeclaration dataSourceClass) {
// Create CodeTypeDeclaration
// Type is internal if any TableAdapter is internal
//
TypeAttributes typeAttributes = TypeAttributes.Public;
foreach (DesignTable table in dataSource.DesignTables) {
if ((table.DataAccessorModifier & TypeAttributes.Public) != TypeAttributes.Public) {
typeAttributes = table.DataAccessorModifier;
}
}
CodeTypeDeclaration dataComponentClass = CodeGenHelper.Class(TableAdapterManagerNameHandler.TableAdapterManagerClassName, true, typeAttributes);
dataComponentClass.Comments.Add(CodeGenHelper.Comment("TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios", true));
dataComponentClass.BaseTypes.Add(CodeGenHelper.GlobalType(typeof(ComponentModel.Component)));
// Set Attributes
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.DesignerAttribute", CodeGenHelper.Str(adapterDesigner + ", " + AssemblyRef.MicrosoftVSDesigner)));
dataComponentClass.CustomAttributes.Add(CodeGenHelper.AttributeDecl(typeof(System.ComponentModel.Design.HelpKeywordAttribute).FullName, CodeGenHelper.Str(helpKeyword)));
// Create and Init the TableAdapterManager Method Generator
TableAdapterManagerMethodGenerator dcMethodGenerator = new TableAdapterManagerMethodGenerator(this.dataSourceGenerator, dataSource, dataSourceClass);
// Generate methods
dcMethodGenerator.AddEverything(dataComponentClass);
// Make sure that what we added so far doesn't contain any code injection (for the queries we're going to add right
// after this all user input is validated in DataComponentNameHandler, so we're safe there).
try {
System.CodeDom.Compiler.CodeGenerator.ValidateIdentifiers(dataComponentClass);
}
catch (Exception er) {
Debug.Fail(er.ToString());
}
return dataComponentClass;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MachineKeyConverter.cs
- BasePattern.cs
- HtmlToClrEventProxy.cs
- HostingEnvironmentWrapper.cs
- PeerPresenceInfo.cs
- OptionalRstParameters.cs
- DBPropSet.cs
- MdImport.cs
- SizeF.cs
- HandledEventArgs.cs
- XmlHelper.cs
- ImageListImageEditor.cs
- CodeObject.cs
- SmiMetaDataProperty.cs
- DataGridCellClipboardEventArgs.cs
- GraphicsPath.cs
- Run.cs
- AutomationPropertyInfo.cs
- Table.cs
- MatrixTransform3D.cs
- InvalidContentTypeException.cs
- State.cs
- AdornerHitTestResult.cs
- GenericUI.cs
- Message.cs
- XmlSchemaAnyAttribute.cs
- FormsAuthenticationConfiguration.cs
- CollectionBase.cs
- ReadWriteSpinLock.cs
- MiniConstructorInfo.cs
- XmlILStorageConverter.cs
- Transform3DGroup.cs
- NullableDoubleMinMaxAggregationOperator.cs
- LineBreak.cs
- WindowsSysHeader.cs
- Literal.cs
- Section.cs
- FixedPageAutomationPeer.cs
- Mapping.cs
- IsolatedStorageFile.cs
- TextTreeUndoUnit.cs
- SamlAuthorizationDecisionStatement.cs
- RadioButtonRenderer.cs
- QueryCacheEntry.cs
- NextPreviousPagerField.cs
- KeyValueConfigurationCollection.cs
- SqlInternalConnection.cs
- BasePropertyDescriptor.cs
- ConnectionModeReader.cs
- DesignerActionHeaderItem.cs
- TextDecorationCollection.cs
- SharedPerformanceCounter.cs
- TrustManagerPromptUI.cs
- SqlFlattener.cs
- MissingMethodException.cs
- XMLDiffLoader.cs
- BaseParagraph.cs
- DataControlButton.cs
- SqlServer2KCompatibilityCheck.cs
- DataPagerFieldCollection.cs
- TextServicesPropertyRanges.cs
- coordinatorfactory.cs
- ADMembershipProvider.cs
- ByteFacetDescriptionElement.cs
- FlowDecisionDesigner.xaml.cs
- FileStream.cs
- AppearanceEditorPart.cs
- CompiledQueryCacheKey.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- InlineCollection.cs
- IsolatedStorageFilePermission.cs
- GetImportFileNameRequest.cs
- WasHostedComPlusFactory.cs
- XamlParser.cs
- TypeSystem.cs
- _IPv6Address.cs
- SecondaryViewProvider.cs
- DragStartedEventArgs.cs
- ColorMap.cs
- ReferenceConverter.cs
- SystemDropShadowChrome.cs
- Message.cs
- ValidationResult.cs
- TextDataBindingHandler.cs
- EntityConnectionStringBuilderItem.cs
- TcpChannelFactory.cs
- XmlSequenceWriter.cs
- AppearanceEditorPart.cs
- UrlAuthFailedErrorFormatter.cs
- HashHelper.cs
- Clause.cs
- Size3DConverter.cs
- BoolExpressionVisitors.cs
- TableLayoutPanelCellPosition.cs
- WebPartsSection.cs
- SqlNodeAnnotation.cs
- EFTableProvider.cs
- PointIndependentAnimationStorage.cs
- IsolatedStorageFile.cs
- RightsManagementManager.cs