Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / DesignTableCollection.cs / 1 / DesignTableCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All Rights Reserved.
// Information Contained Herein is Proprietary and Confidential.
//
//-----------------------------------------------------------------------------
namespace System.Data.Design{
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
///
///
internal class DesignTableCollection : DataSourceCollectionBase {
private DesignDataSource dataSource;
public DesignTableCollection(DesignDataSource dataSource) : base(dataSource) {
this.dataSource = dataSource;
}
private DataSet DataSet{
get{
if (dataSource != null){
return dataSource.DataSet;
}
return null;
}
}
protected override Type ItemType {
get {
return typeof(DesignTable);
}
}
protected override INameService NameService {
get {
return DataSetNameService.DefaultInstance;
}
}
///
///
internal DesignTable this[string name] {
get {
return (DesignTable)FindObject(name);
}
}
///
///
internal DesignTable this[DataTable dataTable] {
get {
foreach (DesignTable designTable in this) {
if (designTable.DataTable == dataTable) {
return designTable;
}
}
return null;
}
}
///
/// Will throw if name is invalid or a dup
/// Add the DataTable to the dataTable if not added yet
///
public void Add(DesignTable designTable){
//
List.Add(designTable);
}
public bool Contains( DesignTable table ) {
return List.Contains( table );
}
public int IndexOf( DesignTable table ) {
return List.IndexOf( table );
}
public void Remove( DesignTable table ) {
List.Remove( table );
}
///
/// Note: this function need to call base first
/// to ensure the undo model work!
///
protected override void OnInsert( int index, object value ) {
base.OnInsert(index, value);
DesignTable designTable = (DesignTable)value;
if (designTable.Name == null || designTable.Name.Length == 0) {
designTable.Name = CreateUniqueName(designTable);
}
NameService.ValidateUniqueName(this, designTable.Name);
if( (this.dataSource != null) && (designTable.Owner == this.dataSource) ) {
Debug.Fail( "Table already belongs to this DataSource" );
return; // no-op
}
if( (this.dataSource != null) && (designTable.Owner != null) ) {
throw new InternalException( VSDExceptions.DataSource.TABLE_BELONGS_TO_OTHER_DATA_SOURCE_MSG,
VSDExceptions.DataSource.TABLE_BELONGS_TO_OTHER_DATA_SOURCE_CODE );
}
DataSet dataSet = DataSet;
if ((dataSet != null) && (!dataSet.Tables.Contains(designTable.DataTable.TableName))) {
Debug.Assert( this.dataSource != null, "If we were able to get the DataSet we should have a design time data source as well" );
dataSet.Tables.Add(designTable.DataTable);
}
designTable.Owner = this.dataSource;
}
///
/// Remove the DataTable in the dataTable if not removed yet
/// Note: this function need to call base first
/// to ensure the undo model work!
///
protected override void OnRemove( int index, object value ) {
base.OnRemove(index, value);
DesignTable designTable = (DesignTable)value;
DataSet dataSet = DataSet;
if (dataSet != null && designTable.DataTable != null
&& dataSet.Tables.Contains(designTable.DataTable.TableName)){
dataSet.Tables.Remove(designTable.DataTable);
}
designTable.Owner = null;
}
}
}
// 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
- HwndStylusInputProvider.cs
- RsaSecurityTokenAuthenticator.cs
- ContainsRowNumberChecker.cs
- LocationUpdates.cs
- EntityViewGenerationAttribute.cs
- HttpRuntime.cs
- TextTreeDeleteContentUndoUnit.cs
- _NegotiateClient.cs
- ValidatorCollection.cs
- HealthMonitoringSection.cs
- InputLangChangeRequestEvent.cs
- TransferRequestHandler.cs
- AnnotationAuthorChangedEventArgs.cs
- streamingZipPartStream.cs
- OpCopier.cs
- RectangleGeometry.cs
- XD.cs
- HwndSource.cs
- HeaderedItemsControl.cs
- Oid.cs
- InvokeHandlers.cs
- ClientSponsor.cs
- Int16AnimationUsingKeyFrames.cs
- ConnectionStringsExpressionBuilder.cs
- CqlErrorHelper.cs
- IDReferencePropertyAttribute.cs
- ServiceBusyException.cs
- XmlUTF8TextWriter.cs
- CodeGeneratorOptions.cs
- SmiConnection.cs
- MaskedTextBox.cs
- SHA256Managed.cs
- EventLogConfiguration.cs
- NameValueConfigurationElement.cs
- ReadOnlyDataSource.cs
- AuthenticationModuleElementCollection.cs
- KeyValuePair.cs
- InputLangChangeRequestEvent.cs
- DoubleCollectionConverter.cs
- RegexNode.cs
- TagMapInfo.cs
- SatelliteContractVersionAttribute.cs
- InstrumentationTracker.cs
- TreeWalker.cs
- SystemColorTracker.cs
- AxDesigner.cs
- ParameterToken.cs
- Slider.cs
- XmlChildNodes.cs
- StoreAnnotationsMap.cs
- HMACSHA256.cs
- XmlUtf8RawTextWriter.cs
- URIFormatException.cs
- TabItemWrapperAutomationPeer.cs
- XmlSchemaAll.cs
- StyleReferenceConverter.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- CollectionViewSource.cs
- LowerCaseStringConverter.cs
- StrokeCollectionConverter.cs
- XmlHierarchicalEnumerable.cs
- DelayLoadType.cs
- ActiveXSite.cs
- ParameterRefs.cs
- XmlILOptimizerVisitor.cs
- ListControl.cs
- METAHEADER.cs
- _KerberosClient.cs
- SoapSchemaImporter.cs
- StrongNameUtility.cs
- AtomEntry.cs
- HTTP_SERVICE_CONFIG_URLACL_KEY.cs
- RectangleHotSpot.cs
- BitFlagsGenerator.cs
- PropertyValueChangedEvent.cs
- ObservableCollection.cs
- DropAnimation.xaml.cs
- HttpAsyncResult.cs
- XNameTypeConverter.cs
- ValueType.cs
- Decimal.cs
- WindowsComboBox.cs
- AnnotationObservableCollection.cs
- XmlDataLoader.cs
- MsmqNonTransactedPoisonHandler.cs
- Frame.cs
- EntityClassGenerator.cs
- StreamWithDictionary.cs
- HttpProcessUtility.cs
- BlockUIContainer.cs
- ToolStripSettings.cs
- ChannelRequirements.cs
- ForceCopyBuildProvider.cs
- ToolStripPanel.cs
- ScriptManager.cs
- LinearGradientBrush.cs
- OperationSelectorBehavior.cs
- DataExpression.cs
- SynchronizationLockException.cs
- PropertyChangedEventArgs.cs