Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Configuration / TagMapCollection.cs / 3 / TagMapCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Configuration {
using System;
using System.Xml;
using System.Configuration;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Text;
using System.Web.Util;
using System.Web.UI;
using System.Web.Compilation;
using System.Threading;
using System.Web.Configuration;
using System.Security.Permissions;
[ConfigurationCollection(typeof(TagMapInfo))]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class TagMapCollection : ConfigurationElementCollection {
private static ConfigurationPropertyCollection _properties;
private Hashtable _tagMappings;
static TagMapCollection() {
// Property initialization
_properties = new ConfigurationPropertyCollection();
}
public TagMapCollection() {
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
public TagMapInfo this[int index] {
get {
return (TagMapInfo)BaseGet(index);
}
set {
if (BaseGet(index) != null) {
BaseRemoveAt(index);
}
BaseAdd(index, value);
}
}
public void Add(TagMapInfo tagMapInformation) {
BaseAdd(tagMapInformation);
}
public void Remove(TagMapInfo tagMapInformation) {
BaseRemove(GetElementKey(tagMapInformation));
}
public void Clear() {
BaseClear();
}
protected override ConfigurationElement CreateNewElement() {
return new TagMapInfo();
}
protected override Object GetElementKey(ConfigurationElement element) {
return ((TagMapInfo)element).TagType;
}
internal Hashtable TagTypeMappingInternal {
get {
if (_tagMappings == null) {
lock (this) {
if (_tagMappings == null) {
Hashtable tagMappings = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (TagMapInfo tmi in this) {
Type tagType = ConfigUtil.GetType(tmi.TagType, "tagType", tmi);
Type mappedTagType = ConfigUtil.GetType(tmi.MappedTagType, "mappedTagType", tmi);
if (tagType.IsAssignableFrom(mappedTagType) == false) {
throw new ConfigurationErrorsException(
SR.GetString(
SR.Mapped_type_must_inherit,
tmi.MappedTagType,
tmi.TagType),
tmi.ElementInformation.Properties["mappedTagType"].Source,
tmi.ElementInformation.Properties["mappedTagType"].LineNumber);
}
tagMappings[tagType] = mappedTagType;
}
_tagMappings = tagMappings;
}
}
}
return _tagMappings;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Configuration {
using System;
using System.Xml;
using System.Configuration;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Text;
using System.Web.Util;
using System.Web.UI;
using System.Web.Compilation;
using System.Threading;
using System.Web.Configuration;
using System.Security.Permissions;
[ConfigurationCollection(typeof(TagMapInfo))]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class TagMapCollection : ConfigurationElementCollection {
private static ConfigurationPropertyCollection _properties;
private Hashtable _tagMappings;
static TagMapCollection() {
// Property initialization
_properties = new ConfigurationPropertyCollection();
}
public TagMapCollection() {
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
public TagMapInfo this[int index] {
get {
return (TagMapInfo)BaseGet(index);
}
set {
if (BaseGet(index) != null) {
BaseRemoveAt(index);
}
BaseAdd(index, value);
}
}
public void Add(TagMapInfo tagMapInformation) {
BaseAdd(tagMapInformation);
}
public void Remove(TagMapInfo tagMapInformation) {
BaseRemove(GetElementKey(tagMapInformation));
}
public void Clear() {
BaseClear();
}
protected override ConfigurationElement CreateNewElement() {
return new TagMapInfo();
}
protected override Object GetElementKey(ConfigurationElement element) {
return ((TagMapInfo)element).TagType;
}
internal Hashtable TagTypeMappingInternal {
get {
if (_tagMappings == null) {
lock (this) {
if (_tagMappings == null) {
Hashtable tagMappings = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (TagMapInfo tmi in this) {
Type tagType = ConfigUtil.GetType(tmi.TagType, "tagType", tmi);
Type mappedTagType = ConfigUtil.GetType(tmi.MappedTagType, "mappedTagType", tmi);
if (tagType.IsAssignableFrom(mappedTagType) == false) {
throw new ConfigurationErrorsException(
SR.GetString(
SR.Mapped_type_must_inherit,
tmi.MappedTagType,
tmi.TagType),
tmi.ElementInformation.Properties["mappedTagType"].Source,
tmi.ElementInformation.Properties["mappedTagType"].LineNumber);
}
tagMappings[tagType] = mappedTagType;
}
_tagMappings = tagMappings;
}
}
}
return _tagMappings;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CommonDialog.cs
- CommandHelpers.cs
- WebPartHelpVerb.cs
- IndexedString.cs
- BrowserDefinitionCollection.cs
- FixedSOMLineCollection.cs
- EntityViewGenerator.cs
- PrintPageEvent.cs
- ToolStripGrip.cs
- XmlObjectSerializerReadContextComplexJson.cs
- Int16Animation.cs
- WebPartTransformerCollection.cs
- CodeDOMProvider.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- QilStrConcat.cs
- SymbolTable.cs
- DbException.cs
- LostFocusEventManager.cs
- AuthorizationSection.cs
- XPathScanner.cs
- WebPartZoneBase.cs
- WindowsStatic.cs
- PathBox.cs
- DirectoryLocalQuery.cs
- ResXFileRef.cs
- ButtonBaseAutomationPeer.cs
- WindowShowOrOpenTracker.cs
- ParameterModifier.cs
- GridViewRow.cs
- ServicePrincipalNameElement.cs
- DocumentOrderQuery.cs
- ObjectDataSourceDisposingEventArgs.cs
- OleDragDropHandler.cs
- XmlElement.cs
- EntityKey.cs
- WebControlsSection.cs
- ResourceContainer.cs
- OdbcEnvironmentHandle.cs
- Attribute.cs
- CompositeControlDesigner.cs
- MailHeaderInfo.cs
- RequestNavigateEventArgs.cs
- BrowserDefinition.cs
- SmiMetaData.cs
- CodeSnippetTypeMember.cs
- OrderToken.cs
- VisualTransition.cs
- ProfessionalColors.cs
- ToolStripManager.cs
- XmlNullResolver.cs
- FillErrorEventArgs.cs
- WebPartZoneCollection.cs
- XmlElementList.cs
- XpsDigitalSignature.cs
- SamlAuthorizationDecisionStatement.cs
- SqlDataSourceCommandEventArgs.cs
- CngAlgorithmGroup.cs
- DataGridViewLayoutData.cs
- XmlSchemaException.cs
- SafeNativeMethods.cs
- SimpleWebHandlerParser.cs
- CompositeScriptReference.cs
- XmlDataCollection.cs
- dbenumerator.cs
- SponsorHelper.cs
- GridViewDeletedEventArgs.cs
- ErrorView.xaml.cs
- CodeMemberEvent.cs
- ForAllOperator.cs
- ErrorWebPart.cs
- GridViewDeleteEventArgs.cs
- NativeWindow.cs
- DataGridItem.cs
- Parser.cs
- Quaternion.cs
- ProfileGroupSettingsCollection.cs
- DependencyPropertyAttribute.cs
- TreeWalkHelper.cs
- XPathNodeHelper.cs
- SeekStoryboard.cs
- ConstrainedDataObject.cs
- SplitterCancelEvent.cs
- ToolStripItemCollection.cs
- AutomationPropertyInfo.cs
- IRCollection.cs
- XsltOutput.cs
- SafeRightsManagementSessionHandle.cs
- TextRangeEdit.cs
- ThrowHelper.cs
- IntranetCredentialPolicy.cs
- CursorEditor.cs
- BatchServiceHost.cs
- UniformGrid.cs
- BinaryFormatter.cs
- HttpWebRequest.cs
- XPathScanner.cs
- IndentedTextWriter.cs
- ParsedAttributeCollection.cs
- SystemIPv4InterfaceProperties.cs
- Span.cs