Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Configuration / System / Configuration / ConnectionStringSettingsCollection.cs / 1 / 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
- ValueConversionAttribute.cs
- DrawingAttributes.cs
- BooleanKeyFrameCollection.cs
- LazyInitializer.cs
- ItemCollection.cs
- PenLineCapValidation.cs
- HttpResponseHeader.cs
- FieldNameLookup.cs
- CurrentTimeZone.cs
- OrderPreservingPipeliningMergeHelper.cs
- ProxyAttribute.cs
- AliasGenerator.cs
- RuleSetDialog.Designer.cs
- SecurityUtils.cs
- CfgParser.cs
- RouteTable.cs
- CodeDefaultValueExpression.cs
- FamilyMapCollection.cs
- AggregateNode.cs
- Attributes.cs
- InvokeHandlers.cs
- ClientTarget.cs
- IntSecurity.cs
- BamlTreeMap.cs
- DataGridAutoFormatDialog.cs
- CompilationPass2Task.cs
- SQLDecimal.cs
- FlowchartDesignerCommands.cs
- ListViewUpdateEventArgs.cs
- followingsibling.cs
- GZipObjectSerializer.cs
- IItemProperties.cs
- FlowLayoutPanel.cs
- Stroke2.cs
- MessageQueuePermissionEntry.cs
- FixedFlowMap.cs
- ChangePassword.cs
- FixedHyperLink.cs
- Rfc4050KeyFormatter.cs
- OutKeywords.cs
- GlyphInfoList.cs
- HtmlGenericControl.cs
- DataSourceCacheDurationConverter.cs
- Tokenizer.cs
- OptimalBreakSession.cs
- securitycriticaldataformultiplegetandset.cs
- UnorderedHashRepartitionStream.cs
- RegexCode.cs
- TiffBitmapDecoder.cs
- ClientFormsAuthenticationCredentials.cs
- Table.cs
- CreateBookmarkScope.cs
- CompressionTracing.cs
- State.cs
- AdornedElementPlaceholder.cs
- SQLRoleProvider.cs
- TableDetailsCollection.cs
- TraceHandler.cs
- CFStream.cs
- Random.cs
- BitmapEffectGroup.cs
- SplitContainer.cs
- CompositeKey.cs
- UrlPath.cs
- MenuItemCollection.cs
- OleDbConnectionInternal.cs
- CategoryAttribute.cs
- NextPreviousPagerField.cs
- ClockGroup.cs
- RootBuilder.cs
- AssociationTypeEmitter.cs
- ValidationException.cs
- ConnectionProviderAttribute.cs
- ImpersonateTokenRef.cs
- DateTimeParse.cs
- ButtonAutomationPeer.cs
- OdbcErrorCollection.cs
- PropertyGrid.cs
- GradientStop.cs
- StatusBar.cs
- OleDbEnumerator.cs
- SymLanguageVendor.cs
- XmlCodeExporter.cs
- DecimalConverter.cs
- ServicePointManagerElement.cs
- WebHttpSecurity.cs
- IDataContractSurrogate.cs
- WindowsFormsHelpers.cs
- WebPartTransformer.cs
- PowerModeChangedEventArgs.cs
- ResourceSet.cs
- ProfileEventArgs.cs
- Int64.cs
- GregorianCalendarHelper.cs
- Transform3DCollection.cs
- SqlDataSourceCache.cs
- AuthenticationException.cs
- TreeViewDesigner.cs
- CancelEventArgs.cs
- PhysicalAddress.cs