Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / DataSourceCollectionBase.cs / 1 / DataSourceCollectionBase.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.ComponentModel;
using System.Diagnostics;
using System.Globalization;
///
///
internal abstract class DataSourceCollectionBase : CollectionBase, INamedObjectCollection, IObjectWithParent {
private DataSourceComponent collectionHost;
internal DataSourceCollectionBase(DataSourceComponent collectionHost) {
this.collectionHost = collectionHost;
}
internal virtual DataSourceComponent CollectionHost {
get {
return this.collectionHost;
}
set {
this.collectionHost = value;
}
}
protected virtual Type ItemType {
get {
return typeof(IDataSourceNamedObject);
}
}
protected abstract INameService NameService {
get;
}
[Browsable(false)]
object IObjectWithParent.Parent {
get {
return this.collectionHost;
}
}
protected virtual string CreateUniqueName(IDataSourceNamedObject value) {
string suggestedName = StringUtil.NotEmpty(value.Name) ?
value.Name :
value.PublicTypeName;
return NameService.CreateUniqueName(this, suggestedName, 1);
}
///
/// This function will check to see namedObject have a name conflict with the names
/// used in the collection and fix the name for namedObject if there is a conflict
///
///
internal protected virtual void EnsureUniqueName(IDataSourceNamedObject namedObject) {
if (namedObject.Name == null || namedObject.Name.Length == 0 || this.FindObject(namedObject.Name) != null) {
namedObject.Name = CreateUniqueName(namedObject);
}
}
internal virtual protected IDataSourceNamedObject FindObject(string name) {
IEnumerator e = this.InnerList.GetEnumerator();
while( e.MoveNext() ) {
IDataSourceNamedObject existing = (IDataSourceNamedObject) e.Current;
if (StringUtil.EqualValue(existing.Name, name)) {
return existing;
}
}
return null;
}
public void InsertBefore(object value, object refObject) {
int index = List.IndexOf(refObject);
if (index >= 0) {
List.Insert(index, value);
}
else {
List.Add(value);
}
}
protected override void OnValidate( object value ) {
base.OnValidate( value );
ValidateType( value );
}
public void Remove(string name) {
INamedObject obj = NamedObjectUtil.Find( this, name );
if( obj != null ) {
this.List.Remove( obj );
}
}
///
/// This function only check the name to be valid, typically used by Insert function, which already ensure the name is unique
///
///
internal protected virtual void ValidateName(IDataSourceNamedObject obj) {
this.NameService.ValidateName(obj.Name);
}
///
/// This function checks the name to be unique and valid, typically used by rename
///
///
///
internal protected virtual void ValidateUniqueName(IDataSourceNamedObject obj, string proposedName) {
this.NameService.ValidateUniqueName(this, obj, proposedName);
}
protected void ValidateType( object value ) {
if (!ItemType.IsInstanceOfType(value)) {
throw new InternalException(VSDExceptions.DataSource.INVALID_COLLECTIONTYPE_MSG, VSDExceptions.DataSource.INVALID_COLLECTIONTYPE_CODE, true);
}
}
public INameService GetNameService() {
return NameService;
}
}
}
// 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
- FileResponseElement.cs
- BitmapFrameEncode.cs
- DockPanel.cs
- ApplicationServiceManager.cs
- StoragePropertyMapping.cs
- ObjectParameter.cs
- MimeWriter.cs
- MimeParameter.cs
- ConfigurationFileMap.cs
- WebBrowserEvent.cs
- RoleManagerModule.cs
- FontCacheLogic.cs
- ProcessHost.cs
- PersianCalendar.cs
- SimpleHandlerFactory.cs
- SqlUDTStorage.cs
- Stylesheet.cs
- SafeIUnknown.cs
- XamlSerializerUtil.cs
- ButtonDesigner.cs
- StringWriter.cs
- PieceNameHelper.cs
- ZipIOBlockManager.cs
- UInt32Converter.cs
- FormViewPageEventArgs.cs
- Scalars.cs
- TaskHelper.cs
- ConfigurationManager.cs
- RunWorkerCompletedEventArgs.cs
- InvalidOperationException.cs
- DocumentAutomationPeer.cs
- ParameterEditorUserControl.cs
- EncryptedPackageFilter.cs
- BinaryObjectWriter.cs
- UTF8Encoding.cs
- ScrollChrome.cs
- DateTimeSerializationSection.cs
- ToolStripDropDown.cs
- IdleTimeoutMonitor.cs
- TdsParserSafeHandles.cs
- SoapFaultCodes.cs
- MLangCodePageEncoding.cs
- FormCollection.cs
- ObjectListCommandsPage.cs
- HMACSHA256.cs
- ToolStripRenderer.cs
- SecurityPermission.cs
- KeyConverter.cs
- _SingleItemRequestCache.cs
- CompositeActivityDesigner.cs
- HttpApplication.cs
- AccessControlEntry.cs
- PromptBuilder.cs
- TextBoxRenderer.cs
- NetworkStream.cs
- TreeBuilderXamlTranslator.cs
- GetWinFXPath.cs
- FormatPage.cs
- InkPresenterAutomationPeer.cs
- RegexTree.cs
- TransformedBitmap.cs
- LongValidator.cs
- GlyphingCache.cs
- DataSvcMapFile.cs
- HttpPostLocalhostServerProtocol.cs
- PowerModeChangedEventArgs.cs
- QilName.cs
- TextEditorSpelling.cs
- PersistenceTypeAttribute.cs
- UrlPropertyAttribute.cs
- LinkedList.cs
- WindowsRichEditRange.cs
- AliasedSlot.cs
- Point3DKeyFrameCollection.cs
- unsafeIndexingFilterStream.cs
- TemplateParser.cs
- Label.cs
- QuaternionAnimation.cs
- EventProviderTraceListener.cs
- ProtocolsConfigurationEntry.cs
- UnknownBitmapDecoder.cs
- ColorTranslator.cs
- UserControl.cs
- DataGridViewRowConverter.cs
- DLinqTableProvider.cs
- CodePrimitiveExpression.cs
- NewItemsContextMenuStrip.cs
- RelationshipFixer.cs
- SqlCacheDependency.cs
- ReaderWriterLockSlim.cs
- COM2Properties.cs
- GlyphingCache.cs
- QilNode.cs
- DetailsViewCommandEventArgs.cs
- XPathItem.cs
- SoundPlayer.cs
- SimpleHandlerBuildProvider.cs
- Int32Collection.cs
- PassportAuthenticationModule.cs
- FastEncoderWindow.cs