Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / Serialization / Configuration / XmlSerializerSection.cs / 2 / 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
- XmlWrappingReader.cs
- HostingEnvironmentException.cs
- ProcessHostConfigUtils.cs
- ContextStack.cs
- SystemDiagnosticsSection.cs
- ClientSession.cs
- HashHelpers.cs
- ActivityDesignerHelper.cs
- SrgsElementFactoryCompiler.cs
- StorageConditionPropertyMapping.cs
- MetadataPropertyCollection.cs
- PrintDialogDesigner.cs
- EventProvider.cs
- DataGridAutomationPeer.cs
- SQLMoneyStorage.cs
- ParameterRetriever.cs
- XhtmlTextWriter.cs
- SoapReflectionImporter.cs
- ReaderWriterLock.cs
- InProcStateClientManager.cs
- ViewStateModeByIdAttribute.cs
- XPathAncestorIterator.cs
- IntegerFacetDescriptionElement.cs
- RuleRefElement.cs
- Timeline.cs
- BinaryObjectReader.cs
- ConnectionManagementElementCollection.cs
- FormViewCommandEventArgs.cs
- StateBag.cs
- RuntimeConfigLKG.cs
- DataFormats.cs
- TypeToken.cs
- SHA512.cs
- DeviceSpecific.cs
- Transform3DCollection.cs
- ProcessHostFactoryHelper.cs
- UIElementIsland.cs
- TabPanel.cs
- BrushProxy.cs
- PropertyTab.cs
- BindingGroup.cs
- EntitySqlException.cs
- OutputCacheSettingsSection.cs
- GCHandleCookieTable.cs
- FloaterParaClient.cs
- SimpleWorkerRequest.cs
- ProcessModuleDesigner.cs
- DataGridItem.cs
- BindMarkupExtensionSerializer.cs
- UnitySerializationHolder.cs
- SQLDecimal.cs
- ClientSection.cs
- Panel.cs
- EventLogHandle.cs
- NCryptNative.cs
- CodeDomLocalizationProvider.cs
- Event.cs
- RayHitTestParameters.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- CallbackBehaviorAttribute.cs
- SiteMapSection.cs
- ImportContext.cs
- HwndSourceParameters.cs
- TextServicesProperty.cs
- Model3DGroup.cs
- TreeNodeCollection.cs
- StatusBarPanel.cs
- ToolStripCustomTypeDescriptor.cs
- DependencyPropertyDescriptor.cs
- AutoGeneratedField.cs
- ButtonBase.cs
- DragEventArgs.cs
- TextViewBase.cs
- storepermissionattribute.cs
- _ContextAwareResult.cs
- UriParserTemplates.cs
- ProfilePropertySettings.cs
- PolygonHotSpot.cs
- odbcmetadatacollectionnames.cs
- ProtocolsConfigurationEntry.cs
- Root.cs
- ListItemCollection.cs
- CredentialCache.cs
- XmlSerializerSection.cs
- CustomMenuItemCollection.cs
- TraceEventCache.cs
- UnsafeMethods.cs
- MainMenu.cs
- Location.cs
- NumericUpDownAccelerationCollection.cs
- PackageRelationship.cs
- RayHitTestParameters.cs
- UrlPropertyAttribute.cs
- SubpageParagraph.cs
- CustomActivityDesigner.cs
- WebPartTransformerCollection.cs
- Wildcard.cs
- NotFiniteNumberException.cs
- EntityCollection.cs
- FullTextBreakpoint.cs