Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Xml / System / Xml / Serialization / Configuration / XmlSerializerSection.cs / 4 / 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. 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
- ZipIOExtraField.cs
- ExpressionServices.cs
- EnumDataContract.cs
- CngKeyCreationParameters.cs
- SqlUnionizer.cs
- GiveFeedbackEvent.cs
- DataTableMappingCollection.cs
- PowerModeChangedEventArgs.cs
- InputChannel.cs
- SafePEFileHandle.cs
- ReturnValue.cs
- Predicate.cs
- lengthconverter.cs
- ViewStateException.cs
- HttpProfileGroupBase.cs
- DiagnosticTrace.cs
- DeriveBytes.cs
- XPathNodeList.cs
- XmlCharacterData.cs
- ContractNamespaceAttribute.cs
- Config.cs
- CachedFontFace.cs
- WinEventWrap.cs
- Rfc2898DeriveBytes.cs
- EventWaitHandleSecurity.cs
- CategoryAttribute.cs
- CryptoProvider.cs
- SendKeys.cs
- PreservationFileWriter.cs
- WindowsAuthenticationModule.cs
- ToolStripActionList.cs
- HitTestDrawingContextWalker.cs
- EncryptedKey.cs
- DataMemberFieldConverter.cs
- IdentityManager.cs
- tooltip.cs
- Path.cs
- XPathExpr.cs
- CodeCatchClauseCollection.cs
- SafeSecurityHandles.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- MarkupExtensionSerializer.cs
- PointCollection.cs
- PrimitiveXmlSerializers.cs
- Function.cs
- FacetDescriptionElement.cs
- QilReference.cs
- CheckBoxStandardAdapter.cs
- EffectiveValueEntry.cs
- SyntaxCheck.cs
- BooleanExpr.cs
- IIS7UserPrincipal.cs
- SurrogateEncoder.cs
- DispatchWrapper.cs
- XamlBrushSerializer.cs
- MutexSecurity.cs
- MetadataArtifactLoaderCompositeResource.cs
- ReversePositionQuery.cs
- MissingMethodException.cs
- WindowsImpersonationContext.cs
- Int64Converter.cs
- MarkupObject.cs
- XPathSelectionIterator.cs
- OleServicesContext.cs
- RuleInfoComparer.cs
- ObjectItemNoOpAssemblyLoader.cs
- SQLStringStorage.cs
- OdbcConnectionOpen.cs
- SqlDeflator.cs
- SqlDataAdapter.cs
- WebControlsSection.cs
- SqlDataSourceSelectingEventArgs.cs
- StringArrayConverter.cs
- MsmqAppDomainProtocolHandler.cs
- TabControl.cs
- LayoutTable.cs
- LinearQuaternionKeyFrame.cs
- HttpServerUtilityWrapper.cs
- ProxyManager.cs
- TrackBarRenderer.cs
- OlePropertyStructs.cs
- _OSSOCK.cs
- HelpEvent.cs
- CodeChecksumPragma.cs
- SoapConverter.cs
- Compensation.cs
- CatalogZone.cs
- ManifestResourceInfo.cs
- FileRecordSequenceHelper.cs
- CodeDomSerializerBase.cs
- ByteStreamMessageEncoder.cs
- DbConnectionHelper.cs
- NamespaceListProperty.cs
- Adorner.cs
- ObjectStateFormatter.cs
- DictionaryMarkupSerializer.cs
- AuthenticationModuleElementCollection.cs
- Cursor.cs
- FileEnumerator.cs
- assemblycache.cs