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
- ContextMenuAutomationPeer.cs
- Proxy.cs
- SmtpAuthenticationManager.cs
- _TransmitFileOverlappedAsyncResult.cs
- PatternMatcher.cs
- Message.cs
- RectKeyFrameCollection.cs
- codemethodreferenceexpression.cs
- FileVersionInfo.cs
- objectquery_tresulttype.cs
- AssociatedControlConverter.cs
- SystemIPv6InterfaceProperties.cs
- IOThreadScheduler.cs
- FixedTextSelectionProcessor.cs
- Int32Animation.cs
- EmptyElement.cs
- TimestampInformation.cs
- _NetworkingPerfCounters.cs
- AsynchronousChannel.cs
- FixedSchema.cs
- PasswordRecovery.cs
- EntityClientCacheEntry.cs
- _SSPISessionCache.cs
- ManipulationVelocities.cs
- SqlFacetAttribute.cs
- Attribute.cs
- ModelFunction.cs
- UIElementHelper.cs
- SiteMapPathDesigner.cs
- GZipUtils.cs
- shaper.cs
- HostedHttpTransportManager.cs
- SamlAuthorizationDecisionStatement.cs
- LinearQuaternionKeyFrame.cs
- FolderBrowserDialog.cs
- Glyph.cs
- ObjectKeyFrameCollection.cs
- AmbientValueAttribute.cs
- PageStatePersister.cs
- ActivityStatusChangeEventArgs.cs
- cookieexception.cs
- ScaleTransform.cs
- ISFClipboardData.cs
- HttpModuleActionCollection.cs
- ServiceOperationListItem.cs
- RegistrationServices.cs
- User.cs
- ControlPropertyNameConverter.cs
- BindingExpressionUncommonField.cs
- QuotedStringFormatReader.cs
- ClientUrlResolverWrapper.cs
- AudioLevelUpdatedEventArgs.cs
- ColumnHeader.cs
- RegisteredArrayDeclaration.cs
- XmlBoundElement.cs
- LogAppendAsyncResult.cs
- QilIterator.cs
- Message.cs
- OdbcParameterCollection.cs
- HMACSHA1.cs
- CustomMenuItemCollection.cs
- Bitmap.cs
- CharKeyFrameCollection.cs
- SqlDataSourceCommandEventArgs.cs
- InfoCardSchemas.cs
- URLAttribute.cs
- TabControlAutomationPeer.cs
- BitmapEffectInputConnector.cs
- WindowsPrincipal.cs
- UIElementParaClient.cs
- NotifyInputEventArgs.cs
- CommandLibraryHelper.cs
- SqlProviderUtilities.cs
- ArgumentsParser.cs
- AnonymousIdentificationSection.cs
- NullEntityWrapper.cs
- HtmlInputRadioButton.cs
- StructuredTypeInfo.cs
- HandlerMappingMemo.cs
- PropertyChangedEventArgs.cs
- WebPartDisplayModeCollection.cs
- ProxyWebPart.cs
- HttpHandler.cs
- DataGridViewImageCell.cs
- Statements.cs
- RadioButtonPopupAdapter.cs
- EntitySetDataBindingList.cs
- ParameterSubsegment.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ButtonChrome.cs
- AssemblyBuilder.cs
- ParameterDataSourceExpression.cs
- ObjectStateFormatter.cs
- TypeConverterAttribute.cs
- UnescapedXmlDiagnosticData.cs
- CanonicalFontFamilyReference.cs
- BuildManager.cs
- ContentPresenter.cs
- WCFBuildProvider.cs
- AnonymousIdentificationSection.cs