Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Configuration / TagMapCollection.cs / 5 / 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.
//
//-----------------------------------------------------------------------------
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RoleManagerModule.cs
- RuleAction.cs
- RubberbandSelector.cs
- RtfControlWordInfo.cs
- ExtendedPropertyDescriptor.cs
- ConfigurationManager.cs
- ParameterBuilder.cs
- XsdBuildProvider.cs
- KnownBoxes.cs
- TimestampInformation.cs
- DateTimeOffsetStorage.cs
- RedistVersionInfo.cs
- XmlQuerySequence.cs
- BuildProviderUtils.cs
- UInt32Storage.cs
- HtmlLink.cs
- BrushProxy.cs
- DigitalSignatureProvider.cs
- _NtlmClient.cs
- GetBrowserTokenRequest.cs
- HttpsTransportElement.cs
- TextFindEngine.cs
- ApplicationFileParser.cs
- EditingContext.cs
- QueryAccessibilityHelpEvent.cs
- PersistenceException.cs
- XmlCharacterData.cs
- RayMeshGeometry3DHitTestResult.cs
- RequiredFieldValidator.cs
- PbrsForward.cs
- DataServiceProcessingPipeline.cs
- EventMap.cs
- ScriptReference.cs
- Vector3dCollection.cs
- XPathNavigatorKeyComparer.cs
- SimpleApplicationHost.cs
- HttpCookiesSection.cs
- VirtualDirectoryMappingCollection.cs
- GridViewPageEventArgs.cs
- NameScope.cs
- HttpRequest.cs
- Int32.cs
- TouchDevice.cs
- RequestSecurityTokenSerializer.cs
- UnhandledExceptionEventArgs.cs
- RootProfilePropertySettingsCollection.cs
- XmlDesignerDataSourceView.cs
- MissingMemberException.cs
- BinaryMessageEncodingBindingElement.cs
- RelationshipWrapper.cs
- ObservableCollectionDefaultValueFactory.cs
- NativeMethods.cs
- SimpleBitVector32.cs
- StringValueConverter.cs
- LexicalChunk.cs
- DataGridCellAutomationPeer.cs
- NamespaceCollection.cs
- RowToFieldTransformer.cs
- UInt32.cs
- Registry.cs
- OdbcRowUpdatingEvent.cs
- PassportAuthenticationModule.cs
- SqlServices.cs
- GridLength.cs
- XPathItem.cs
- SimpleWebHandlerParser.cs
- SystemWebExtensionsSectionGroup.cs
- PaintValueEventArgs.cs
- CodeValidator.cs
- BulletedList.cs
- Point3DCollection.cs
- MetadataItem.cs
- EntitySqlQueryState.cs
- VirtualizingStackPanel.cs
- TabItem.cs
- DoubleCollectionValueSerializer.cs
- ServiceContractDetailViewControl.cs
- CopyNamespacesAction.cs
- PageHandlerFactory.cs
- PointLightBase.cs
- NoResizeHandleGlyph.cs
- DataRecordInfo.cs
- UIElement.cs
- UriParserTemplates.cs
- TagPrefixCollection.cs
- ImageKeyConverter.cs
- Int32EqualityComparer.cs
- SslStream.cs
- InternalDuplexBindingElement.cs
- PageThemeBuildProvider.cs
- WindowsSpinner.cs
- InputScopeNameConverter.cs
- SerialPinChanges.cs
- WindowsRegion.cs
- MemberInitExpression.cs
- MatrixCamera.cs
- querybuilder.cs
- EventSetter.cs
- OSEnvironmentHelper.cs
- DesignerDataTableBase.cs