Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / Configuration / ConvertersCollection.cs / 1305376 / ConvertersCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Configuration {
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Web;
using System.Web.Compilation;
using System.Web.Resources;
using System.Web.Script.Serialization;
using System.Security;
[
ConfigurationCollection(typeof(Converter)),
SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface",
Justification="Derives from legacy collection base class. Base method IsReadOnly() " +
"would clash with property ICollection.IsReadOnly.")
]
public class ConvertersCollection : ConfigurationElementCollection {
private static readonly ConfigurationPropertyCollection _properties =
new ConfigurationPropertyCollection();
public ConvertersCollection() {
}
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
public Converter this[int index] {
get {
return (Converter)BaseGet(index);
}
set {
if (BaseGet(index) != null) {
BaseRemoveAt(index);
}
BaseAdd(index, value);
}
}
public void Add(Converter converter) {
BaseAdd(converter);
}
public void Remove(Converter converter) {
BaseRemove(GetElementKey(converter));
}
public void Clear() {
BaseClear();
}
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
protected override ConfigurationElement CreateNewElement() {
return new Converter();
}
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
protected override Object GetElementKey(ConfigurationElement element) {
return ((Converter)element).Name;
}
[SecuritySafeCritical]
internal JavaScriptConverter[] CreateConverters() {
List list = new List();
foreach (Converter converter in this) {
Type t = BuildManager.GetType(converter.Type, false /*throwOnError*/);
if (t == null) {
throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ConvertersCollection_UnknownType, converter.Type));
}
if (!typeof(JavaScriptConverter).IsAssignableFrom(t)) {
throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ConvertersCollection_NotJavaScriptConverter, t.Name));
}
list.Add((JavaScriptConverter)Activator.CreateInstance(t));
}
return list.ToArray();
}
}
}
// 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.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Web;
using System.Web.Compilation;
using System.Web.Resources;
using System.Web.Script.Serialization;
using System.Security;
[
ConfigurationCollection(typeof(Converter)),
SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface",
Justification="Derives from legacy collection base class. Base method IsReadOnly() " +
"would clash with property ICollection.IsReadOnly.")
]
public class ConvertersCollection : ConfigurationElementCollection {
private static readonly ConfigurationPropertyCollection _properties =
new ConfigurationPropertyCollection();
public ConvertersCollection() {
}
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
public Converter this[int index] {
get {
return (Converter)BaseGet(index);
}
set {
if (BaseGet(index) != null) {
BaseRemoveAt(index);
}
BaseAdd(index, value);
}
}
public void Add(Converter converter) {
BaseAdd(converter);
}
public void Remove(Converter converter) {
BaseRemove(GetElementKey(converter));
}
public void Clear() {
BaseClear();
}
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
protected override ConfigurationElement CreateNewElement() {
return new Converter();
}
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
protected override Object GetElementKey(ConfigurationElement element) {
return ((Converter)element).Name;
}
[SecuritySafeCritical]
internal JavaScriptConverter[] CreateConverters() {
List list = new List();
foreach (Converter converter in this) {
Type t = BuildManager.GetType(converter.Type, false /*throwOnError*/);
if (t == null) {
throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ConvertersCollection_UnknownType, converter.Type));
}
if (!typeof(JavaScriptConverter).IsAssignableFrom(t)) {
throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ConvertersCollection_NotJavaScriptConverter, t.Name));
}
list.Add((JavaScriptConverter)Activator.CreateInstance(t));
}
return list.ToArray();
}
}
}
// 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
- XPSSignatureDefinition.cs
- PenThreadPool.cs
- SqlDataSourceCache.cs
- AxHost.cs
- SqlDataSourceCommandEventArgs.cs
- Vector3DKeyFrameCollection.cs
- UriTemplateTable.cs
- TdsParserSessionPool.cs
- __ConsoleStream.cs
- AssociationProvider.cs
- DomainUpDown.cs
- StringInfo.cs
- FormsAuthenticationModule.cs
- PowerModeChangedEventArgs.cs
- BatchParser.cs
- JulianCalendar.cs
- Cursors.cs
- RuntimeConfig.cs
- NavigatorOutput.cs
- ArrangedElementCollection.cs
- HttpRawResponse.cs
- Closure.cs
- DependencyPropertyConverter.cs
- XmlDataDocument.cs
- ColorConverter.cs
- OleDbConnection.cs
- ColumnWidthChangedEvent.cs
- SchemaElementLookUpTable.cs
- ExceptQueryOperator.cs
- XsltLibrary.cs
- _Win32.cs
- ReturnEventArgs.cs
- Configuration.cs
- XmlSchemaType.cs
- RelatedPropertyManager.cs
- ProfileBuildProvider.cs
- ParserContext.cs
- ActivityExecutorSurrogate.cs
- ContractsBCL.cs
- ISO2022Encoding.cs
- DataGridViewRowCollection.cs
- BaseValidator.cs
- FixedSOMTableCell.cs
- SchemaMapping.cs
- XmlSchemaAnyAttribute.cs
- WebPartEditorApplyVerb.cs
- HttpModuleActionCollection.cs
- StringFreezingAttribute.cs
- GroupItem.cs
- DSASignatureDeformatter.cs
- ProvidePropertyAttribute.cs
- DefaultTextStoreTextComposition.cs
- IntAverageAggregationOperator.cs
- _ListenerAsyncResult.cs
- Schema.cs
- EncodingDataItem.cs
- MailMessage.cs
- ImportCatalogPart.cs
- uribuilder.cs
- WindowsGraphics.cs
- Label.cs
- UnsafeNativeMethodsMilCoreApi.cs
- LinqDataSourceValidationException.cs
- DuplicateWaitObjectException.cs
- Slider.cs
- TextProperties.cs
- DataGridViewRowPrePaintEventArgs.cs
- Run.cs
- StreamInfo.cs
- _SingleItemRequestCache.cs
- XmlSchemaInclude.cs
- RenamedEventArgs.cs
- WebPartTransformerCollection.cs
- DriveInfo.cs
- RootBrowserWindowProxy.cs
- TextTreeInsertUndoUnit.cs
- OleDbSchemaGuid.cs
- _SSPISessionCache.cs
- WebPartDescription.cs
- LocalFileSettingsProvider.cs
- ObjectIDGenerator.cs
- WebScriptServiceHost.cs
- SingleKeyFrameCollection.cs
- UnionCodeGroup.cs
- FormViewDeleteEventArgs.cs
- COM2IDispatchConverter.cs
- WebPartZoneBaseDesigner.cs
- WebRequestModuleElement.cs
- Opcode.cs
- CornerRadius.cs
- ContractListAdapter.cs
- ResourceReferenceKeyNotFoundException.cs
- XmlNodeReader.cs
- NotifyParentPropertyAttribute.cs
- AppliedDeviceFiltersEditor.cs
- PermissionListSet.cs
- TagMapInfo.cs
- ChameleonKey.cs
- MeshGeometry3D.cs
- Package.cs