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
- TabControl.cs
- FileDialog.cs
- HitTestParameters.cs
- HtmlButton.cs
- TrackingServices.cs
- ComboBoxRenderer.cs
- CodeParameterDeclarationExpression.cs
- RemoteCryptoRsaServiceProvider.cs
- MaskedTextProvider.cs
- DataGridTextBoxColumn.cs
- RuntimeCompatibilityAttribute.cs
- StoreAnnotationsMap.cs
- SecuritySessionFilter.cs
- TreeNodeBinding.cs
- JsonReader.cs
- IdentityReference.cs
- PlatformNotSupportedException.cs
- TextAction.cs
- ClassDataContract.cs
- MissingManifestResourceException.cs
- CodeGotoStatement.cs
- PermissionSetTriple.cs
- DataGridViewSortCompareEventArgs.cs
- FixedBufferAttribute.cs
- CacheRequest.cs
- KnownBoxes.cs
- HtmlInputCheckBox.cs
- SafeNativeHandle.cs
- IdentityHolder.cs
- ValueUnavailableException.cs
- LingerOption.cs
- BigInt.cs
- Pair.cs
- ExpandCollapseProviderWrapper.cs
- ContextMarshalException.cs
- Animatable.cs
- UserControlCodeDomTreeGenerator.cs
- TreeNodeCollection.cs
- NativeActivityMetadata.cs
- TraceLog.cs
- WeakReadOnlyCollection.cs
- WebPartActionVerb.cs
- Utility.cs
- HttpBrowserCapabilitiesWrapper.cs
- LoginName.cs
- SubpageParaClient.cs
- DynamicILGenerator.cs
- Missing.cs
- QilUnary.cs
- QuaternionRotation3D.cs
- SamlAudienceRestrictionCondition.cs
- ContextDataSource.cs
- AbandonedMutexException.cs
- SchemaImporterExtensionElement.cs
- Animatable.cs
- SimpleApplicationHost.cs
- EventManager.cs
- PriorityItem.cs
- Enum.cs
- ListSortDescription.cs
- FilterQuery.cs
- CryptoKeySecurity.cs
- Mutex.cs
- MultipartContentParser.cs
- CodeVariableReferenceExpression.cs
- SymbolType.cs
- XsltFunctions.cs
- ISAPIRuntime.cs
- UnsafeNativeMethods.cs
- SAPIEngineTypes.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- TerminatorSinks.cs
- SystemIcmpV6Statistics.cs
- WebBrowser.cs
- SettingsAttributes.cs
- FileClassifier.cs
- ScrollItemPattern.cs
- ConditionalDesigner.cs
- Delay.cs
- MsmqChannelFactory.cs
- FamilyMapCollection.cs
- PropertyDescriptorCollection.cs
- FieldToken.cs
- ACE.cs
- ControlCachePolicy.cs
- SynchronizedDispatch.cs
- TableTextElementCollectionInternal.cs
- RSAOAEPKeyExchangeDeformatter.cs
- NullableDoubleAverageAggregationOperator.cs
- ContentPlaceHolder.cs
- ListViewHitTestInfo.cs
- Rijndael.cs
- RegistryPermission.cs
- DeclarationUpdate.cs
- ImageSource.cs
- HandledEventArgs.cs
- DesignerAdapterUtil.cs
- SharedDp.cs
- SchemaNamespaceManager.cs
- IItemProperties.cs