Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / NameHandler.cs / 1 / NameHandler.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All Rights Reserved.
// Information Contained Herein is Proprietary and Confidential.
//
//-----------------------------------------------------------------------------
namespace System.Data.Design {
using System;
using System.Data;
using System.CodeDom;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.CodeDom.Compiler;
using System.ComponentModel.Design;
using System.ComponentModel;
internal sealed class NameHandler {
private const string FunctionsTableName = "Queries";
private DataSourceNameHandler dataSourceHandler = null;
private static CodeDomProvider codeProvider = null;
private bool languageCaseInsensitive = false;
private static Hashtable lookupIdentifiers;
internal NameHandler(CodeDomProvider codeProvider) {
if(codeProvider == null) {
throw new ArgumentException("codeProvider");
}
NameHandler.codeProvider = codeProvider;
}
internal void GenerateMemberNames(DesignDataSource dataSource, ArrayList problemList) {
if(dataSource == null || codeProvider == null) {
throw new InternalException("DesignDataSource or/and CodeDomProvider parameters are null.");
}
// init the lookup-identifiers hashtable; we need this for compatibility with WebData's generator
InitLookupIdentifiers();
// generate names for DataSource-class members
dataSourceHandler = new DataSourceNameHandler();
dataSourceHandler.GenerateMemberNames(dataSource, codeProvider, this.languageCaseInsensitive, problemList);
foreach (DesignTable table in dataSource.DesignTables) {
// create table name handler
DataTableNameHandler currentTableHandler = new DataTableNameHandler();
currentTableHandler.GenerateMemberNames(table, codeProvider, this.languageCaseInsensitive, problemList);
// create component name handler
DataComponentNameHandler currentComponentHandler = new DataComponentNameHandler();
currentComponentHandler.GenerateMemberNames(table, codeProvider, this.languageCaseInsensitive, problemList);
}
// process names for the 'Functions' component
if (dataSource.Sources != null && dataSource.Sources.Count > 0) {
// create a 'fake' table and set names and sources on it
DesignTable functionsTable = new DesignTable();
functionsTable.TableType = TableType.RadTable;
functionsTable.DataAccessorName = dataSource.FunctionsComponentName;
functionsTable.UserDataComponentName = dataSource.UserFunctionsComponentName;
functionsTable.GeneratorDataComponentClassName = dataSource.GeneratorFunctionsComponentClassName;
foreach (Source source in dataSource.Sources) {
functionsTable.Sources.Add(source);
}
// do the name generation for the fake table
DataComponentNameHandler functionsComponentHandler = new DataComponentNameHandler();
functionsComponentHandler.GlobalSources = true;
functionsComponentHandler.GenerateMemberNames(functionsTable, codeProvider, this.languageCaseInsensitive, problemList);
// copy the generated names back to the DesignDataSource, we'll use them when generating the FunctionsDataComponent
dataSource.GeneratorFunctionsComponentClassName = functionsTable.GeneratorDataComponentClassName;
}
}
internal static string FixIdName(string inVarName) {
if (lookupIdentifiers == null) {
InitLookupIdentifiers();
}
string newName = (string)lookupIdentifiers[inVarName];
if (newName == null) {
newName = MemberNameValidator.GenerateIdName(inVarName, codeProvider, false /*useSuffix*/);
while (lookupIdentifiers.ContainsValue(newName)) {
newName = '_' + newName;
}
lookupIdentifiers[inVarName] = newName;
}
return newName;
}
private static void InitLookupIdentifiers() {
lookupIdentifiers = new Hashtable();
System.Reflection.PropertyInfo[] props = typeof(DataRow).GetProperties();
foreach (System.Reflection.PropertyInfo p in props) {
lookupIdentifiers[p.Name] = '_' + p.Name;
}
}
}
}
// 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
- Resources.Designer.cs
- XLinq.cs
- ArrayList.cs
- IIS7UserPrincipal.cs
- _SSPIWrapper.cs
- HtmlShimManager.cs
- ConditionCollection.cs
- WebPartTransformerAttribute.cs
- DrawingContextWalker.cs
- DbProviderFactory.cs
- CellParaClient.cs
- XsltException.cs
- ReflectEventDescriptor.cs
- TypeElement.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- ScriptManager.cs
- ThicknessAnimationBase.cs
- Expr.cs
- FormClosedEvent.cs
- ParserHooks.cs
- Slider.cs
- HighlightComponent.cs
- SqlTriggerContext.cs
- PresentationTraceSources.cs
- XmlNotation.cs
- XmlAggregates.cs
- TabControl.cs
- CriticalExceptions.cs
- DataGridViewColumnDesigner.cs
- EqualityComparer.cs
- OleDbCommandBuilder.cs
- SmiEventSink.cs
- newitemfactory.cs
- VideoDrawing.cs
- ListBindingConverter.cs
- XmlDataProvider.cs
- Geometry3D.cs
- TextTreeUndo.cs
- Rectangle.cs
- XamlHostingSection.cs
- SHA384.cs
- FloatAverageAggregationOperator.cs
- IntegerValidator.cs
- InputLanguageProfileNotifySink.cs
- EnumerableRowCollection.cs
- ByteStorage.cs
- DateTimeFormat.cs
- RegisteredHiddenField.cs
- TabItemAutomationPeer.cs
- ConnectionInterfaceCollection.cs
- ShapeTypeface.cs
- GPPOINT.cs
- WsatServiceCertificate.cs
- GuidTagList.cs
- LinearKeyFrames.cs
- ReferenceCountedObject.cs
- HitTestDrawingContextWalker.cs
- Vars.cs
- xsdvalidator.cs
- XmlSignificantWhitespace.cs
- PointHitTestParameters.cs
- HtmlHead.cs
- ListMarkerLine.cs
- DataGridViewColumnCollectionEditor.cs
- ProgressBar.cs
- BridgeDataRecord.cs
- Region.cs
- ImageBrush.cs
- XmlSchemas.cs
- WindowsProgressbar.cs
- DnsPermission.cs
- FieldMetadata.cs
- CodeTypeParameter.cs
- ModelFunctionTypeElement.cs
- TemplateKeyConverter.cs
- RotationValidation.cs
- FocusChangedEventArgs.cs
- _NestedSingleAsyncResult.cs
- PropertyDescriptorCollection.cs
- LingerOption.cs
- QueryStringParameter.cs
- ContentElement.cs
- ToolStripComboBox.cs
- BaseTemplateParser.cs
- DataMemberFieldConverter.cs
- ConnectionAcceptor.cs
- BlockUIContainer.cs
- XmlQueryOutput.cs
- DPTypeDescriptorContext.cs
- SystemColors.cs
- MultiBindingExpression.cs
- CngProvider.cs
- ProcessingInstructionAction.cs
- updatecommandorderer.cs
- BamlRecordWriter.cs
- ListControlDataBindingHandler.cs
- EventLogEntryCollection.cs
- CustomCategoryAttribute.cs
- WindowsClaimSet.cs
- HttpUnhandledOperationInvoker.cs