Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Serialization / Configuration / XmlSerializerSection.cs / 1305376 / XmlSerializerSection.cs
namespace System.Xml.Serialization.Configuration { using System; using System.IO; using System.Web; using System.Configuration; using System.ComponentModel; using System.Globalization; using System.Reflection; using System.Resources; public sealed class XmlSerializerSection : ConfigurationSection { public XmlSerializerSection() { this.properties.Add(this.checkDeserializeAdvances); this.properties.Add(this.tempFilesLocation); } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } [ConfigurationProperty(ConfigurationStrings.CheckDeserializeAdvances, DefaultValue = false)] public bool CheckDeserializeAdvances { get { return (bool)this[this.checkDeserializeAdvances]; } set { this[this.checkDeserializeAdvances] = value; } } [ConfigurationProperty(ConfigurationStrings.TempFilesLocation, DefaultValue = null)] public string TempFilesLocation { get { return (string)this[this.tempFilesLocation]; } set { this[this.tempFilesLocation] = value; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); // Supply a type converter, even though it's a plain type converter, to get around ConfigurationProperty's internal // Enum conversion routine. The internal one is case-sensitive, we want this to be case-insensitive. readonly ConfigurationProperty checkDeserializeAdvances = new ConfigurationProperty(ConfigurationStrings.CheckDeserializeAdvances, typeof(bool), false, ConfigurationPropertyOptions.None); readonly ConfigurationProperty tempFilesLocation = new ConfigurationProperty(ConfigurationStrings.TempFilesLocation, typeof(string), null, null, new RootedPathValidator(), ConfigurationPropertyOptions.None); } public class RootedPathValidator : ConfigurationValidatorBase { public override bool CanValidate(Type type) { return (type == typeof(string)); } public override void Validate(object value) { string tempDirectory = value as string; if (string.IsNullOrEmpty(tempDirectory)) return; tempDirectory = tempDirectory.Trim(); if (string.IsNullOrEmpty(tempDirectory)) return; if (!Path.IsPathRooted(tempDirectory)) { // Make sure the path is not relative (VSWhidbey 260075) throw new ConfigurationErrorsException(); } char firstChar = tempDirectory[0]; if (firstChar == Path.DirectorySeparatorChar || firstChar == Path.AltDirectorySeparatorChar) { // Make sure the path is explicitly rooted throw new ConfigurationErrorsException(); } } } } // 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
- DataObjectFieldAttribute.cs
- FactoryMaker.cs
- DataGridViewSortCompareEventArgs.cs
- HttpApplication.cs
- AstNode.cs
- XmlTextReaderImplHelpers.cs
- CreatingCookieEventArgs.cs
- DataGridLinkButton.cs
- Int32Animation.cs
- WindowsFormsHostAutomationPeer.cs
- QuotedPrintableStream.cs
- SoapReflectionImporter.cs
- XmlSchemaAll.cs
- SafeFindHandle.cs
- ComboBoxAutomationPeer.cs
- FontStretches.cs
- WebHttpElement.cs
- CustomErrorCollection.cs
- MetadataArtifactLoaderComposite.cs
- CleanUpVirtualizedItemEventArgs.cs
- DataColumnMapping.cs
- handlecollector.cs
- XamlReaderHelper.cs
- RefreshPropertiesAttribute.cs
- Fonts.cs
- Ops.cs
- BinaryExpression.cs
- RealProxy.cs
- CachedPathData.cs
- UniqueConstraint.cs
- XmlSchemaInclude.cs
- DocumentPageViewAutomationPeer.cs
- ThrowHelper.cs
- RtfControls.cs
- BaseResourcesBuildProvider.cs
- OdbcConnectionPoolProviderInfo.cs
- ContentElement.cs
- ComponentResourceManager.cs
- HttpCookiesSection.cs
- ClientConfigurationSystem.cs
- ColumnMapTranslator.cs
- RequiredArgumentAttribute.cs
- MemberDomainMap.cs
- XamlStyleSerializer.cs
- DispatcherExceptionFilterEventArgs.cs
- TabletDeviceInfo.cs
- StylusCaptureWithinProperty.cs
- SerialStream.cs
- COM2ExtendedBrowsingHandler.cs
- CaseCqlBlock.cs
- XPathNavigatorKeyComparer.cs
- SessionPageStatePersister.cs
- EventLogQuery.cs
- XmlObjectSerializerWriteContextComplex.cs
- XmlTextReaderImplHelpers.cs
- CurrentChangingEventArgs.cs
- EntityWrapper.cs
- EncodingInfo.cs
- WorkflowServiceHostFactory.cs
- LocationInfo.cs
- OdbcReferenceCollection.cs
- Collection.cs
- DataControlImageButton.cs
- FrameworkElementFactory.cs
- DocobjHost.cs
- TypeConstant.cs
- TranslateTransform.cs
- TraceHandlerErrorFormatter.cs
- KeyMatchBuilder.cs
- PageWrapper.cs
- PanelStyle.cs
- Component.cs
- SettingsPropertyValue.cs
- TreeNodeEventArgs.cs
- StaticFileHandler.cs
- MissingMethodException.cs
- DocumentOutline.cs
- CommandID.cs
- OneOfConst.cs
- InsufficientMemoryException.cs
- DesignerPerfEventProvider.cs
- OleDbPermission.cs
- SimpleRecyclingCache.cs
- AddingNewEventArgs.cs
- ColumnHeader.cs
- CompModSwitches.cs
- AtomServiceDocumentSerializer.cs
- SspiNegotiationTokenProvider.cs
- Dictionary.cs
- _UriSyntax.cs
- ReachUIElementCollectionSerializer.cs
- Base64Encoder.cs
- AccessDataSource.cs
- CanExecuteRoutedEventArgs.cs
- OleServicesContext.cs
- ReferenceEqualityComparer.cs
- DiscoveryMessageSequence11.cs
- TableProvider.cs
- AtomPub10ServiceDocumentFormatter.cs
- BaseAddressElement.cs