Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / System / Diagnostics / SourceElementsCollection.cs / 1 / SourceElementsCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
namespace System.Diagnostics {
[ConfigurationCollection(typeof(SourceElement), AddItemName = "source",
CollectionType = ConfigurationElementCollectionType.BasicMap)]
internal class SourceElementsCollection : ConfigurationElementCollection {
new public SourceElement this[string name] {
get {
return (SourceElement) BaseGet(name);
}
}
protected override string ElementName {
get {
return "source";
}
}
public override ConfigurationElementCollectionType CollectionType {
get {
return ConfigurationElementCollectionType.BasicMap;
}
}
protected override ConfigurationElement CreateNewElement() {
SourceElement se = new SourceElement();
se.Listeners.InitializeDefaultInternal();
return se;
}
protected override Object GetElementKey(ConfigurationElement element) {
return ((SourceElement) element).Name;
}
}
internal class SourceElement : ConfigurationElement {
private static readonly ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired);
private static readonly ConfigurationProperty _propSwitchName = new ConfigurationProperty("switchName", typeof(string), null, ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propSwitchValue = new ConfigurationProperty("switchValue", typeof(string), null, ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propSwitchType = new ConfigurationProperty("switchType", typeof(string), null, ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propListeners = new ConfigurationProperty("listeners", typeof(ListenerElementsCollection), new ListenerElementsCollection(), ConfigurationPropertyOptions.None);
private Hashtable _attributes;
static SourceElement() {
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propName);
_properties.Add(_propSwitchName);
_properties.Add(_propSwitchValue);
_properties.Add(_propSwitchType);
_properties.Add(_propListeners);
}
public Hashtable Attributes {
get {
if (_attributes == null)
_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
return _attributes;
}
}
[ConfigurationProperty("listeners")]
public ListenerElementsCollection Listeners {
get {
return (ListenerElementsCollection) this[_propListeners];
}
}
[ConfigurationProperty("name", IsRequired=true, DefaultValue="")]
public string Name {
get {
return (string) this[_propName];
}
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
[ConfigurationProperty("switchName")]
public string SwitchName {
get {
return (string) this[_propSwitchName];
}
}
[ConfigurationProperty("switchValue")]
public string SwitchValue {
get {
return (string) this[_propSwitchValue];
}
}
[ConfigurationProperty("switchType")]
public string SwitchType {
get {
return (string) this[_propSwitchType];
}
}
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
{
base.DeserializeElement(reader, serializeCollectionKey);
if (!String.IsNullOrEmpty(SwitchName) && !String.IsNullOrEmpty(SwitchValue))
throw new ConfigurationErrorsException(SR.GetString(SR.Only_specify_one, Name));
}
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(_propSwitchName);
_properties.Add(_propSwitchValue);
_properties.Add(_propSwitchType);
_properties.Add(_propListeners);
}
}
}
}
// 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;
using System.Xml;
namespace System.Diagnostics {
[ConfigurationCollection(typeof(SourceElement), AddItemName = "source",
CollectionType = ConfigurationElementCollectionType.BasicMap)]
internal class SourceElementsCollection : ConfigurationElementCollection {
new public SourceElement this[string name] {
get {
return (SourceElement) BaseGet(name);
}
}
protected override string ElementName {
get {
return "source";
}
}
public override ConfigurationElementCollectionType CollectionType {
get {
return ConfigurationElementCollectionType.BasicMap;
}
}
protected override ConfigurationElement CreateNewElement() {
SourceElement se = new SourceElement();
se.Listeners.InitializeDefaultInternal();
return se;
}
protected override Object GetElementKey(ConfigurationElement element) {
return ((SourceElement) element).Name;
}
}
internal class SourceElement : ConfigurationElement {
private static readonly ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired);
private static readonly ConfigurationProperty _propSwitchName = new ConfigurationProperty("switchName", typeof(string), null, ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propSwitchValue = new ConfigurationProperty("switchValue", typeof(string), null, ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propSwitchType = new ConfigurationProperty("switchType", typeof(string), null, ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propListeners = new ConfigurationProperty("listeners", typeof(ListenerElementsCollection), new ListenerElementsCollection(), ConfigurationPropertyOptions.None);
private Hashtable _attributes;
static SourceElement() {
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propName);
_properties.Add(_propSwitchName);
_properties.Add(_propSwitchValue);
_properties.Add(_propSwitchType);
_properties.Add(_propListeners);
}
public Hashtable Attributes {
get {
if (_attributes == null)
_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
return _attributes;
}
}
[ConfigurationProperty("listeners")]
public ListenerElementsCollection Listeners {
get {
return (ListenerElementsCollection) this[_propListeners];
}
}
[ConfigurationProperty("name", IsRequired=true, DefaultValue="")]
public string Name {
get {
return (string) this[_propName];
}
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
[ConfigurationProperty("switchName")]
public string SwitchName {
get {
return (string) this[_propSwitchName];
}
}
[ConfigurationProperty("switchValue")]
public string SwitchValue {
get {
return (string) this[_propSwitchValue];
}
}
[ConfigurationProperty("switchType")]
public string SwitchType {
get {
return (string) this[_propSwitchType];
}
}
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
{
base.DeserializeElement(reader, serializeCollectionKey);
if (!String.IsNullOrEmpty(SwitchName) && !String.IsNullOrEmpty(SwitchValue))
throw new ConfigurationErrorsException(SR.GetString(SR.Only_specify_one, Name));
}
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(_propSwitchName);
_properties.Add(_propSwitchValue);
_properties.Add(_propSwitchType);
_properties.Add(_propListeners);
}
}
}
}
// 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
- MetadataArtifactLoader.cs
- SqlAliasesReferenced.cs
- columnmapfactory.cs
- Command.cs
- documentsequencetextcontainer.cs
- DBParameter.cs
- DataViewSetting.cs
- GridViewRowEventArgs.cs
- CatchBlock.cs
- UInt64Storage.cs
- DebugHandleTracker.cs
- HierarchicalDataBoundControl.cs
- XmlILIndex.cs
- ColumnResizeAdorner.cs
- OracleCommandSet.cs
- SolidColorBrush.cs
- CompositeActivityTypeDescriptorProvider.cs
- XmlName.cs
- PolyLineSegment.cs
- DerivedKeySecurityToken.cs
- BorderGapMaskConverter.cs
- XmlNodeList.cs
- XmlSchemaObjectCollection.cs
- InfoCardAsymmetricCrypto.cs
- CommandTreeTypeHelper.cs
- mactripleDES.cs
- PeerConnector.cs
- StylusPointDescription.cs
- TimeEnumHelper.cs
- ConfigurationSectionHelper.cs
- configsystem.cs
- PropertyChangeTracker.cs
- PagedDataSource.cs
- BevelBitmapEffect.cs
- RC2CryptoServiceProvider.cs
- SecurityChannel.cs
- CancelEventArgs.cs
- HotCommands.cs
- AdapterDictionary.cs
- ControlDesigner.cs
- ResXBuildProvider.cs
- RequestQueryParser.cs
- TrustManagerMoreInformation.cs
- ParallelTimeline.cs
- ElementNotAvailableException.cs
- BrowserCapabilitiesCodeGenerator.cs
- ObjectFullSpanRewriter.cs
- ToolStripRenderEventArgs.cs
- webproxy.cs
- MobileListItemCollection.cs
- DescendantOverDescendantQuery.cs
- ServiceNotStartedException.cs
- StringCollectionEditor.cs
- CompilerError.cs
- SystemDiagnosticsSection.cs
- StylusPointPropertyId.cs
- configsystem.cs
- FileInfo.cs
- XmlBoundElement.cs
- BitmapCacheBrush.cs
- RSAPKCS1SignatureDeformatter.cs
- SystemUdpStatistics.cs
- _ShellExpression.cs
- ListViewGroup.cs
- PolygonHotSpot.cs
- CodeVariableDeclarationStatement.cs
- WindowsStatic.cs
- Int32Converter.cs
- FrameworkElementFactoryMarkupObject.cs
- FusionWrap.cs
- StorageMappingItemCollection.cs
- InvokeBinder.cs
- HyperLinkStyle.cs
- Identity.cs
- MSAAEventDispatcher.cs
- GeometryGroup.cs
- OperationInfo.cs
- CroppedBitmap.cs
- SQLBytesStorage.cs
- LinqDataSourceView.cs
- TextCompositionManager.cs
- GenericNameHandler.cs
- ConvertTextFrag.cs
- HostingEnvironment.cs
- TemplateBindingExpressionConverter.cs
- Queue.cs
- AVElementHelper.cs
- SapiAttributeParser.cs
- MSAAWinEventWrap.cs
- SwitchLevelAttribute.cs
- ListenerElementsCollection.cs
- MarkupCompilePass1.cs
- AppDomainAttributes.cs
- TreeIterator.cs
- TranslateTransform.cs
- ConnectionPoolManager.cs
- DataTemplateKey.cs
- SemanticResolver.cs
- FirstQueryOperator.cs
- Add.cs