Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / DataComponentGenerator.cs / 4 / DataComponentGenerator.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.Reflection;
using System.Globalization;
using System.CodeDom.Compiler;
using System.Runtime.InteropServices;
internal sealed class DataComponentGenerator {
private TypedDataSourceCodeGenerator dataSourceGenerator = null;
private static string adapterDesigner = "Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner";
internal DataComponentGenerator(TypedDataSourceCodeGenerator codeGenerator) {
this.dataSourceGenerator = codeGenerator;
}
// internal CodeTypeDeclaration GenerateDataComponentInterface(DesignTable designTable, bool isFunctionsComponent) {
// // Get DataComponent class Name
// string dataComponentInterfaceName = designTable.GeneratorDataComponentInterfaceName;
//
// // Create CodeTypeDeclaration
// CodeTypeDeclaration dataComponentInterface = new CodeTypeDeclaration(dataComponentInterfaceName);
// dataComponentInterface.IsInterface = true;
// dataComponentInterface.Attributes = MemberAttributes.Public;
//
// // create handler for queries
// QueryHandler queryHandler = new QueryHandler(this.dataSourceGenerator, designTable);
// queryHandler.DeclarationsOnly = true;
//
// // generate query declarations on DataComponent interface
// if(isFunctionsComponent) {
// queryHandler.AddFunctionsToDataComponent(dataComponentInterface, true /*skipMain*/);
// }
// else {
// queryHandler.AddQueriesToDataComponent(dataComponentInterface);
// }
//
// return dataComponentInterface;
// }
internal CodeTypeDeclaration GenerateDataComponent(DesignTable designTable, bool isFunctionsComponent, bool generateHierarchicalUpdate){
// Get DataComponent class Name
string dataComponentClassName = designTable.GeneratorDataComponentClassName;
// Create CodeTypeDeclaration
CodeTypeDeclaration dataComponentClass = CodeGenHelper.Class(dataComponentClassName, true, designTable.DataAccessorModifier);
// Set BaseType
dataComponentClass.BaseTypes.Add(CodeGenHelper.GlobalType(designTable.BaseClass));
// 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.DataObjectAttribute", 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("vs.data.TableAdapter")));
if (designTable.WebServiceAttribute) {
CodeAttributeDeclaration wsAttribute = new CodeAttributeDeclaration("System.Web.Services.WebService");
wsAttribute.Arguments.Add(new CodeAttributeArgument("Namespace", CodeGenHelper.Str(designTable.WebServiceNamespace)));
wsAttribute.Arguments.Add(new CodeAttributeArgument("Description", CodeGenHelper.Str(designTable.WebServiceDescription)));
dataComponentClass.CustomAttributes.Add(wsAttribute);
}
dataComponentClass.Comments.Add(CodeGenHelper.Comment(@"Represents the connection and commands used to retrieve and save data.",true));
// Create and Init the Typed DataSet Method Generator
DataComponentMethodGenerator dcMethodGenerator = new DataComponentMethodGenerator(this.dataSourceGenerator, designTable, generateHierarchicalUpdate);
// Generate methods
dcMethodGenerator.AddMethods(dataComponentClass, isFunctionsComponent);
// 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).
System.CodeDom.Compiler.CodeGenerator.ValidateIdentifiers(dataComponentClass);
// create handler for queries
QueryHandler queryHandler = new QueryHandler(this.dataSourceGenerator, designTable);
// generate queries on DataComponent
if(isFunctionsComponent) {
queryHandler.AddFunctionsToDataComponent(dataComponentClass, true /*skipMain*/);
}
else {
queryHandler.AddQueriesToDataComponent(dataComponentClass);
}
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
- NullEntityWrapper.cs
- WsatConfiguration.cs
- XmlSchemaExporter.cs
- ValidatedControlConverter.cs
- EventData.cs
- SqlDataSourceCache.cs
- QueueProcessor.cs
- DataGridViewColumnDesigner.cs
- MediaPlayer.cs
- CharUnicodeInfo.cs
- GradientSpreadMethodValidation.cs
- mansign.cs
- ControlIdConverter.cs
- MaterializeFromAtom.cs
- PreviewKeyDownEventArgs.cs
- Propagator.ExtentPlaceholderCreator.cs
- XmlParserContext.cs
- TextElementEditingBehaviorAttribute.cs
- _ConnectionGroup.cs
- DataTableNewRowEvent.cs
- MessagePropertyFilter.cs
- WebConfigurationHostFileChange.cs
- CharacterBufferReference.cs
- TextRangeSerialization.cs
- ACL.cs
- DataExpression.cs
- BindingManagerDataErrorEventArgs.cs
- PrefixQName.cs
- StreamingContext.cs
- DrawingContext.cs
- PropertyValue.cs
- SqlClientPermission.cs
- InputLanguageCollection.cs
- BamlRecordHelper.cs
- CodeAttributeDeclarationCollection.cs
- XmlSchemaSubstitutionGroup.cs
- ObjectStateManagerMetadata.cs
- FreezableOperations.cs
- RequestTimeoutManager.cs
- TypeUtil.cs
- Binding.cs
- SQLBytes.cs
- DateRangeEvent.cs
- MenuDesigner.cs
- RegistryPermission.cs
- PerformanceCounterPermission.cs
- SqlInternalConnection.cs
- WebBrowserNavigatingEventHandler.cs
- RootDesignerSerializerAttribute.cs
- CodeConstructor.cs
- Calendar.cs
- GeneralTransform3DTo2D.cs
- GlyphsSerializer.cs
- ResolveMatches11.cs
- Brush.cs
- PageCache.cs
- PeerName.cs
- Char.cs
- CodeGroup.cs
- DataViewSetting.cs
- ImageMapEventArgs.cs
- RIPEMD160.cs
- RelationshipEndMember.cs
- DbSource.cs
- X509CertificateTrustedIssuerElement.cs
- DataGridViewRowHeaderCell.cs
- TemplateAction.cs
- AspNetPartialTrustHelpers.cs
- LoginView.cs
- AppearanceEditorPart.cs
- RuntimeWrappedException.cs
- UrlMappingCollection.cs
- SystemResources.cs
- ExpandableObjectConverter.cs
- StateManagedCollection.cs
- RectangleHotSpot.cs
- CommunicationObjectAbortedException.cs
- FormCollection.cs
- NullRuntimeConfig.cs
- AttachInfo.cs
- DataGridViewCellStyleConverter.cs
- HotSpotCollection.cs
- ButtonAutomationPeer.cs
- DataBoundControlAdapter.cs
- OlePropertyStructs.cs
- FilteredXmlReader.cs
- SqlDataSourceEnumerator.cs
- WorkflowElementDialog.cs
- TypedReference.cs
- SqlNodeAnnotations.cs
- StringFunctions.cs
- ComplexBindingPropertiesAttribute.cs
- IndentedTextWriter.cs
- SamlEvidence.cs
- IndicCharClassifier.cs
- EventItfInfo.cs
- ADMembershipProvider.cs
- EncryptedPackageFilter.cs
- WindowsPrincipal.cs
- UpdateExpressionVisitor.cs