Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / ConnectionStringSettingsCollection.cs / 1305376 / ConnectionStringSettingsCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.IO; using System.Text; // class ConnectionStringsSection [ConfigurationCollection(typeof(ConnectionStringSettings))] public sealed class ConnectionStringSettingsCollection : ConfigurationElementCollection { private static ConfigurationPropertyCollection _properties; static ConnectionStringSettingsCollection() { // Property initialization _properties = new ConfigurationPropertyCollection(); } protected internal override ConfigurationPropertyCollection Properties { get { return _properties; } } public ConnectionStringSettingsCollection() : base(StringComparer.OrdinalIgnoreCase) { } public ConnectionStringSettings this[int index] { get { return (ConnectionStringSettings)BaseGet(index); } set { if (BaseGet(index) != null) { BaseRemoveAt(index); } BaseAdd(index, value); } } new public ConnectionStringSettings this[string name] { get { return (ConnectionStringSettings)BaseGet(name); } } public int IndexOf(ConnectionStringSettings settings) { return BaseIndexOf(settings); } // the connection string behavior is strange in that is acts kind of like a // basic map and partially like a add remove clear collection // Overriding these methods allows for the specific behaviors to be // patterened protected override void BaseAdd(int index, ConfigurationElement element) { if (index == -1) { BaseAdd(element, false); } else { base.BaseAdd(index, element); } } public void Add(ConnectionStringSettings settings) { BaseAdd(settings); } public void Remove(ConnectionStringSettings settings) { if (BaseIndexOf(settings) >= 0) { BaseRemove(settings.Key); } } public void RemoveAt(int index) { BaseRemoveAt(index); } public void Remove(string name) { BaseRemove(name); } protected override ConfigurationElement CreateNewElement() { return new ConnectionStringSettings(); } protected override Object GetElementKey(ConfigurationElement element) { return ((ConnectionStringSettings)element).Key; } public void Clear() { BaseClear(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.IO; using System.Text; // class ConnectionStringsSection [ConfigurationCollection(typeof(ConnectionStringSettings))] public sealed class ConnectionStringSettingsCollection : ConfigurationElementCollection { private static ConfigurationPropertyCollection _properties; static ConnectionStringSettingsCollection() { // Property initialization _properties = new ConfigurationPropertyCollection(); } protected internal override ConfigurationPropertyCollection Properties { get { return _properties; } } public ConnectionStringSettingsCollection() : base(StringComparer.OrdinalIgnoreCase) { } public ConnectionStringSettings this[int index] { get { return (ConnectionStringSettings)BaseGet(index); } set { if (BaseGet(index) != null) { BaseRemoveAt(index); } BaseAdd(index, value); } } new public ConnectionStringSettings this[string name] { get { return (ConnectionStringSettings)BaseGet(name); } } public int IndexOf(ConnectionStringSettings settings) { return BaseIndexOf(settings); } // the connection string behavior is strange in that is acts kind of like a // basic map and partially like a add remove clear collection // Overriding these methods allows for the specific behaviors to be // patterened protected override void BaseAdd(int index, ConfigurationElement element) { if (index == -1) { BaseAdd(element, false); } else { base.BaseAdd(index, element); } } public void Add(ConnectionStringSettings settings) { BaseAdd(settings); } public void Remove(ConnectionStringSettings settings) { if (BaseIndexOf(settings) >= 0) { BaseRemove(settings.Key); } } public void RemoveAt(int index) { BaseRemoveAt(index); } public void Remove(string name) { BaseRemove(name); } protected override ConfigurationElement CreateNewElement() { return new ConnectionStringSettings(); } protected override Object GetElementKey(ConfigurationElement element) { return ((ConnectionStringSettings)element).Key; } public void Clear() { BaseClear(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ToolStripLocationCancelEventArgs.cs
- CancelEventArgs.cs
- BufferedGraphics.cs
- Util.cs
- XmlQualifiedName.cs
- StandardToolWindows.cs
- FontFaceLayoutInfo.cs
- IntSecurity.cs
- UserInitiatedRoutedEventPermission.cs
- CultureSpecificCharacterBufferRange.cs
- PrefixHandle.cs
- CodeDirectionExpression.cs
- TextStore.cs
- QilInvokeLateBound.cs
- ThaiBuddhistCalendar.cs
- UnsafeNetInfoNativeMethods.cs
- CompensatableTransactionScopeActivity.cs
- ModuleElement.cs
- Sql8ExpressionRewriter.cs
- AdRotator.cs
- ListItemCollection.cs
- DesignerSerializerAttribute.cs
- DataBoundLiteralControl.cs
- Metafile.cs
- RuleAttributes.cs
- FontSizeConverter.cs
- ConnectionManagementSection.cs
- SpotLight.cs
- NamespaceQuery.cs
- DataTemplateKey.cs
- DataGridItemEventArgs.cs
- Visual3D.cs
- MasterPageBuildProvider.cs
- XsdBuildProvider.cs
- MulticastNotSupportedException.cs
- WebPartConnectionsCancelEventArgs.cs
- GradientSpreadMethodValidation.cs
- TreeNodeMouseHoverEvent.cs
- CollectionViewGroupInternal.cs
- TemplateParser.cs
- IndicCharClassifier.cs
- DesignTimeParseData.cs
- DebuggerAttributes.cs
- ScriptModule.cs
- DispatcherFrame.cs
- ScrollEvent.cs
- XhtmlBasicValidationSummaryAdapter.cs
- SqlColumnizer.cs
- QilLoop.cs
- FixedPageAutomationPeer.cs
- ObjectSecurity.cs
- ConnectionPoint.cs
- X509WindowsSecurityToken.cs
- DashStyle.cs
- CookieProtection.cs
- MsmqIntegrationReceiveParameters.cs
- DbParameterCollectionHelper.cs
- DataGridViewHitTestInfo.cs
- DataServiceQuery.cs
- HttpCacheVary.cs
- WebPartZoneAutoFormat.cs
- CompilerTypeWithParams.cs
- ConfigXmlWhitespace.cs
- GridViewColumnHeader.cs
- PeerEndPoint.cs
- StylusDevice.cs
- PageContent.cs
- MailHeaderInfo.cs
- SmtpCommands.cs
- DataGridViewIntLinkedList.cs
- SchemaElement.cs
- ProjectionPath.cs
- DateTimeConstantAttribute.cs
- CngKeyCreationParameters.cs
- ActivityXRefPropertyEditor.cs
- TreeView.cs
- DbgUtil.cs
- FixUpCollection.cs
- TextDecoration.cs
- AsnEncodedData.cs
- DrawingBrush.cs
- MimeMapping.cs
- MarginsConverter.cs
- DockProviderWrapper.cs
- MetadataException.cs
- GridViewRowCollection.cs
- QilFactory.cs
- ControlAdapter.cs
- FormatConvertedBitmap.cs
- VisualProxy.cs
- TCPListener.cs
- SplayTreeNode.cs
- PageContent.cs
- TreeNodeBinding.cs
- CompensatableTransactionScopeActivityDesigner.cs
- BindingCollection.cs
- ConfigurationLocationCollection.cs
- TypeBuilderInstantiation.cs
- MetaData.cs
- DataListCommandEventArgs.cs