Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DbConnectionPool.cs
- SelectionGlyphBase.cs
- DefaultEvaluationContext.cs
- ScriptReferenceEventArgs.cs
- SchemaMapping.cs
- ChainedAsyncResult.cs
- RequestCachePolicy.cs
- Rotation3D.cs
- BitmapCacheBrush.cs
- MachinePropertyVariants.cs
- ClientData.cs
- ColorAnimation.cs
- XmlWrappingReader.cs
- HtmlGenericControl.cs
- StringBuilder.cs
- MediaTimeline.cs
- ParamArrayAttribute.cs
- WebControlParameterProxy.cs
- CancellationHandler.cs
- SqlUserDefinedAggregateAttribute.cs
- CatalogZone.cs
- ConfigXmlComment.cs
- SqlCacheDependencyDatabaseCollection.cs
- WebBrowsableAttribute.cs
- Rectangle.cs
- AdapterUtil.cs
- PkcsUtils.cs
- EncryptedPackage.cs
- RoutedCommand.cs
- NativeActivityTransactionContext.cs
- HttpHeaderCollection.cs
- PropertyIDSet.cs
- DbProviderFactories.cs
- DataSourceSerializationException.cs
- CacheOutputQuery.cs
- QueryGenerator.cs
- WebPartConnectionsConfigureVerb.cs
- TabletDeviceInfo.cs
- _NativeSSPI.cs
- CngKeyCreationParameters.cs
- NamespaceImport.cs
- WebConfigurationFileMap.cs
- SqlNodeTypeOperators.cs
- EntityConnectionStringBuilder.cs
- QueryExpr.cs
- TypeToken.cs
- ScriptingWebServicesSectionGroup.cs
- ContextMenuService.cs
- XmlILConstructAnalyzer.cs
- MinimizableAttributeTypeConverter.cs
- ToggleButton.cs
- FixedSOMElement.cs
- _HeaderInfo.cs
- CqlLexerHelpers.cs
- ScrollableControl.cs
- RoutedPropertyChangedEventArgs.cs
- SmtpMail.cs
- TextCollapsingProperties.cs
- KnownBoxes.cs
- DbQueryCommandTree.cs
- ApplicationDirectory.cs
- _HeaderInfo.cs
- Section.cs
- ProvidersHelper.cs
- ConfigXmlWhitespace.cs
- TrackBar.cs
- SqlInfoMessageEvent.cs
- ParameterModifier.cs
- QilStrConcatenator.cs
- ZipArchive.cs
- DataGridHeaderBorder.cs
- ThreadInterruptedException.cs
- CheckBoxRenderer.cs
- InstanceData.cs
- EditorPart.cs
- SubpageParagraph.cs
- SafeHandle.cs
- RepeatBehavior.cs
- DateTimeConverter.cs
- OutKeywords.cs
- PrintingPermission.cs
- ObjectHandle.cs
- OutOfMemoryException.cs
- TransactionException.cs
- MatrixTransform.cs
- DataViewListener.cs
- CallContext.cs
- FlowStep.cs
- XmlSchemaCollection.cs
- InvokeMethodActivityDesigner.cs
- SoapIncludeAttribute.cs
- FilterQuery.cs
- ReadOnlyAttribute.cs
- ExceptionRoutedEventArgs.cs
- KeyMatchBuilder.cs
- CustomAttributeBuilder.cs
- StringCollectionEditor.cs
- TemplateBamlTreeBuilder.cs
- DataGridViewTopLeftHeaderCell.cs
- FontWeights.cs