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
- Knowncolors.cs
- ListView.cs
- CacheSection.cs
- Matrix.cs
- CopyCodeAction.cs
- OptionalColumn.cs
- EntityDataSourceDesigner.cs
- ParameterCollection.cs
- HttpHandler.cs
- ToolStripMenuItem.cs
- ConstraintStruct.cs
- Site.cs
- PerfCounters.cs
- QuaternionKeyFrameCollection.cs
- UnauthorizedAccessException.cs
- XmlConvert.cs
- StyleHelper.cs
- _ChunkParse.cs
- Walker.cs
- DataServiceRequestOfT.cs
- GridViewRowEventArgs.cs
- XPathSelfQuery.cs
- SelectionProcessor.cs
- StreamAsIStream.cs
- EncodingNLS.cs
- QueryOutputWriter.cs
- OptimisticConcurrencyException.cs
- InstanceNotReadyException.cs
- TakeOrSkipWhileQueryOperator.cs
- XsdDuration.cs
- hwndwrapper.cs
- DoubleAnimationUsingKeyFrames.cs
- XmlILStorageConverter.cs
- BoundField.cs
- EditorAttribute.cs
- XmlDataSourceDesigner.cs
- DataGridParentRows.cs
- DataGridRelationshipRow.cs
- ListControl.cs
- RootAction.cs
- ComplexPropertyEntry.cs
- XmlQueryType.cs
- OleDbException.cs
- QueryValue.cs
- FacetValueContainer.cs
- SelectionEditingBehavior.cs
- WebBrowserSiteBase.cs
- XamlGridLengthSerializer.cs
- DockAndAnchorLayout.cs
- basevalidator.cs
- UnitControl.cs
- HostedNamedPipeTransportManager.cs
- DefaultAutoFieldGenerator.cs
- TreeNode.cs
- TrackingProfileCache.cs
- StateItem.cs
- MailSettingsSection.cs
- RegisteredArrayDeclaration.cs
- WorkflowDesignerColors.cs
- ErrorFormatterPage.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- CollectionViewProxy.cs
- DiagnosticsConfiguration.cs
- Vector3D.cs
- EventHandlingScope.cs
- MachineKey.cs
- BitmapEffectGroup.cs
- DataSourceXmlSerializer.cs
- AutomationAttributeInfo.cs
- GeometryModel3D.cs
- XamlBrushSerializer.cs
- SqlEnums.cs
- GenericEnumerator.cs
- ThreadSafeList.cs
- Rect3D.cs
- _WinHttpWebProxyDataBuilder.cs
- WrapperEqualityComparer.cs
- WizardSideBarListControlItem.cs
- MdbDataFileEditor.cs
- AsymmetricSignatureFormatter.cs
- WebServiceHostFactory.cs
- SettingsPropertyWrongTypeException.cs
- TextDecorations.cs
- XmlTextEncoder.cs
- RegexTree.cs
- TableCellCollection.cs
- FormViewModeEventArgs.cs
- ContainerUtilities.cs
- RectangleF.cs
- WebColorConverter.cs
- TitleStyle.cs
- XPathException.cs
- EntityRecordInfo.cs
- InfoCardAsymmetricCrypto.cs
- QilGeneratorEnv.cs
- RefreshPropertiesAttribute.cs
- ProcessModelInfo.cs
- StringResourceManager.cs
- ApplicationSettingsBase.cs
- basevalidator.cs