Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- PagesChangedEventArgs.cs
- WebPartCollection.cs
- SystemTcpStatistics.cs
- HostedImpersonationContext.cs
- DBCommand.cs
- SafeSystemMetrics.cs
- InstanceDataCollection.cs
- HttpAsyncResult.cs
- WebPartConnectVerb.cs
- SchemaElement.cs
- MouseGestureConverter.cs
- UnicodeEncoding.cs
- UIElementParagraph.cs
- AuthenticationManager.cs
- AutomationEvent.cs
- GeneralTransformGroup.cs
- XPathNode.cs
- TextCompositionManager.cs
- ServiceReference.cs
- Rect3D.cs
- ListBoxAutomationPeer.cs
- TextOptionsInternal.cs
- FacetDescription.cs
- AuthenticationManager.cs
- Attribute.cs
- SqlProfileProvider.cs
- BezierSegment.cs
- SoapInteropTypes.cs
- XmlAnyElementAttribute.cs
- Vector3dCollection.cs
- SecurityElement.cs
- NoClickablePointException.cs
- MouseOverProperty.cs
- ReadContentAsBinaryHelper.cs
- ToolboxSnapDragDropEventArgs.cs
- MessagePartProtectionMode.cs
- SqlDataSourceDesigner.cs
- SqlErrorCollection.cs
- SchemaElement.cs
- Trace.cs
- LineServicesCallbacks.cs
- Propagator.Evaluator.cs
- DataSourceGeneratorException.cs
- AttachInfo.cs
- DispatcherHooks.cs
- ChangeTracker.cs
- Message.cs
- GorillaCodec.cs
- SystemResources.cs
- UnsafeNativeMethodsMilCoreApi.cs
- HashCodeCombiner.cs
- EventMetadata.cs
- Config.cs
- ByteStorage.cs
- LinkedList.cs
- UnsafePeerToPeerMethods.cs
- TableColumnCollectionInternal.cs
- ProtectedConfiguration.cs
- StreamBodyWriter.cs
- SqlFunctionAttribute.cs
- ObjectCloneHelper.cs
- CultureSpecificStringDictionary.cs
- UriParserTemplates.cs
- OdbcDataAdapter.cs
- ImageAutomationPeer.cs
- CollectionChange.cs
- ParallelTimeline.cs
- ResourceExpression.cs
- KerberosRequestorSecurityToken.cs
- MatrixAnimationUsingKeyFrames.cs
- ParameterBuilder.cs
- Globals.cs
- HoistedLocals.cs
- Triplet.cs
- HierarchicalDataTemplate.cs
- ComplexType.cs
- AudioSignalProblemOccurredEventArgs.cs
- NetStream.cs
- RuntimeHandles.cs
- SQlBooleanStorage.cs
- SynchronizedChannelCollection.cs
- RequestSecurityTokenResponse.cs
- KernelTypeValidation.cs
- DefaultShape.cs
- FaultContext.cs
- OutOfMemoryException.cs
- webeventbuffer.cs
- ExternalCalls.cs
- SqlStream.cs
- XmlFormatExtensionAttribute.cs
- PixelFormats.cs
- HashHelpers.cs
- RemotingService.cs
- Types.cs
- XmlNode.cs
- MetadataArtifactLoaderCompositeResource.cs
- DeploymentExceptionMapper.cs
- ErrorRuntimeConfig.cs
- XmlSchemaSimpleContentExtension.cs
- ToolStripHighContrastRenderer.cs