Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / System / Diagnostics / SwitchElementsCollection.cs / 1 / SwitchElementsCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System.Configuration; using System.Collections; using System.Collections.Specialized; namespace System.Diagnostics { [ConfigurationCollection(typeof(SwitchElement))] internal class SwitchElementsCollection : ConfigurationElementCollection { new public SwitchElement this[string name] { get { return (SwitchElement) BaseGet(name); } } public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.AddRemoveClearMap; } } protected override ConfigurationElement CreateNewElement() { return new SwitchElement(); } protected override Object GetElementKey(ConfigurationElement element) { return ((SwitchElement) element).Name; } } internal class SwitchElement : ConfigurationElement { private static readonly ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); private static readonly ConfigurationProperty _propValue = new ConfigurationProperty("value", typeof(string), null, ConfigurationPropertyOptions.IsRequired); private Hashtable _attributes; static SwitchElement(){ _properties = new ConfigurationPropertyCollection(); _properties.Add(_propName); _properties.Add(_propValue); } public Hashtable Attributes { get { if (_attributes == null) _attributes = new Hashtable(StringComparer.OrdinalIgnoreCase); return _attributes; } } [ConfigurationProperty("name", DefaultValue = "", IsRequired = true, IsKey = true)] public string Name { get { return (string) this[_propName]; } } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } [ConfigurationProperty("value", IsRequired = true)] public string Value { get { return (string) this[_propValue]; } } protected override bool OnDeserializeUnrecognizedAttribute(String name, String value) { ConfigurationProperty _propDynamic = new ConfigurationProperty(name, typeof(string), value); _properties.Add(_propDynamic); base[_propDynamic] = value; // Add them to the property bag Attributes.Add(name, value); return true; } internal void ResetProperties() { // blow away any UnrecognizedAttributes that we have deserialized earlier if (_attributes != null) { _attributes.Clear(); _properties.Clear(); _properties.Add(_propName); _properties.Add(_propValue); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System.Configuration; using System.Collections; using System.Collections.Specialized; namespace System.Diagnostics { [ConfigurationCollection(typeof(SwitchElement))] internal class SwitchElementsCollection : ConfigurationElementCollection { new public SwitchElement this[string name] { get { return (SwitchElement) BaseGet(name); } } public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.AddRemoveClearMap; } } protected override ConfigurationElement CreateNewElement() { return new SwitchElement(); } protected override Object GetElementKey(ConfigurationElement element) { return ((SwitchElement) element).Name; } } internal class SwitchElement : ConfigurationElement { private static readonly ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); private static readonly ConfigurationProperty _propValue = new ConfigurationProperty("value", typeof(string), null, ConfigurationPropertyOptions.IsRequired); private Hashtable _attributes; static SwitchElement(){ _properties = new ConfigurationPropertyCollection(); _properties.Add(_propName); _properties.Add(_propValue); } public Hashtable Attributes { get { if (_attributes == null) _attributes = new Hashtable(StringComparer.OrdinalIgnoreCase); return _attributes; } } [ConfigurationProperty("name", DefaultValue = "", IsRequired = true, IsKey = true)] public string Name { get { return (string) this[_propName]; } } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } [ConfigurationProperty("value", IsRequired = true)] public string Value { get { return (string) this[_propValue]; } } protected override bool OnDeserializeUnrecognizedAttribute(String name, String value) { ConfigurationProperty _propDynamic = new ConfigurationProperty(name, typeof(string), value); _properties.Add(_propDynamic); base[_propDynamic] = value; // Add them to the property bag Attributes.Add(name, value); return true; } internal void ResetProperties() { // blow away any UnrecognizedAttributes that we have deserialized earlier if (_attributes != null) { _attributes.Clear(); _properties.Clear(); _properties.Add(_propName); _properties.Add(_propValue); } } } } // 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
- DependencyPropertyKey.cs
- ExternalFile.cs
- ControlAdapter.cs
- _RegBlobWebProxyDataBuilder.cs
- PagerStyle.cs
- Figure.cs
- SHA512CryptoServiceProvider.cs
- ManagedIStream.cs
- XomlCompilerHelpers.cs
- ObjectStateEntryDbDataRecord.cs
- IPEndPoint.cs
- URLAttribute.cs
- PathTooLongException.cs
- Win32.cs
- DataViewManager.cs
- QuotedStringWriteStateInfo.cs
- DeviceContexts.cs
- TextPointer.cs
- XslUrlEditor.cs
- HostingPreferredMapPath.cs
- DeploymentSectionCache.cs
- TextContainer.cs
- DecimalKeyFrameCollection.cs
- DbConnectionPoolIdentity.cs
- SQLMoney.cs
- SqlIdentifier.cs
- RegexInterpreter.cs
- ObjectDataSourceChooseMethodsPanel.cs
- Stroke.cs
- BufferedReceiveElement.cs
- ListView.cs
- RecordManager.cs
- NumericUpDown.cs
- TemplateBindingExtensionConverter.cs
- OdbcEnvironmentHandle.cs
- Int16Storage.cs
- UIHelper.cs
- SelectionChangedEventArgs.cs
- SqlBulkCopyColumnMappingCollection.cs
- DataViewListener.cs
- TreeView.cs
- SourceFileBuildProvider.cs
- DuplexClientBase.cs
- StylusOverProperty.cs
- TcpChannelHelper.cs
- AnnotationObservableCollection.cs
- HtmlImage.cs
- TraceSection.cs
- EntitySqlException.cs
- PropertyContainer.cs
- SoapReflectionImporter.cs
- CompressionTransform.cs
- TemplateKey.cs
- TextEffectResolver.cs
- ToolStripDropDownMenu.cs
- BamlResourceContent.cs
- ControlPaint.cs
- JoinTreeSlot.cs
- PeerNameResolver.cs
- DispatcherHookEventArgs.cs
- MetadataArtifactLoaderCompositeFile.cs
- ProtocolElementCollection.cs
- MimeWriter.cs
- TextMessageEncodingElement.cs
- HtmlInputText.cs
- DoubleAverageAggregationOperator.cs
- AppSecurityManager.cs
- handlecollector.cs
- precedingquery.cs
- Italic.cs
- DomainUpDown.cs
- AutomationIdentifierGuids.cs
- CounterCreationDataCollection.cs
- ISAPIWorkerRequest.cs
- ConstraintEnumerator.cs
- TableHeaderCell.cs
- TypefaceMap.cs
- Int64Animation.cs
- NativeCompoundFileAPIs.cs
- FilterableAttribute.cs
- NonParentingControl.cs
- ConfigXmlCDataSection.cs
- Win32.cs
- MergePropertyDescriptor.cs
- StringUtil.cs
- FixedFindEngine.cs
- PassportAuthenticationEventArgs.cs
- GregorianCalendar.cs
- WebPartExportVerb.cs
- RemoteWebConfigurationHost.cs
- XmlEncodedRawTextWriter.cs
- NominalTypeEliminator.cs
- ListenerConnectionDemuxer.cs
- mactripleDES.cs
- Configuration.cs
- CompressEmulationStream.cs
- COM2FontConverter.cs
- StsCommunicationException.cs
- ReadContentAsBinaryHelper.cs
- CapabilitiesPattern.cs