Code:
/ DotNET / DotNET / 8.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
- TextTabProperties.cs
- TabControlCancelEvent.cs
- TextRangeEditTables.cs
- NullableIntAverageAggregationOperator.cs
- DesignOnlyAttribute.cs
- DataSourceControlBuilder.cs
- SchemeSettingElementCollection.cs
- FixedTextSelectionProcessor.cs
- X509SecurityToken.cs
- CssClassPropertyAttribute.cs
- ColumnResizeAdorner.cs
- BitmapVisualManager.cs
- UrlUtility.cs
- NetPeerTcpBinding.cs
- MatrixAnimationUsingKeyFrames.cs
- tooltip.cs
- CharEntityEncoderFallback.cs
- InkCanvasAutomationPeer.cs
- ImpersonateTokenRef.cs
- Variant.cs
- MappingException.cs
- ISFTagAndGuidCache.cs
- RuntimeWrappedException.cs
- DataRelationCollection.cs
- StringAttributeCollection.cs
- Model3D.cs
- Screen.cs
- StreamGeometry.cs
- KnownBoxes.cs
- LoadGrammarCompletedEventArgs.cs
- DataFieldEditor.cs
- CustomLineCap.cs
- ClearTypeHintValidation.cs
- Scene3D.cs
- ISCIIEncoding.cs
- QueryAccessibilityHelpEvent.cs
- ErrorReporting.cs
- BooleanFacetDescriptionElement.cs
- DesignerWebPartChrome.cs
- InternalSafeNativeMethods.cs
- StructuredType.cs
- DescendantOverDescendantQuery.cs
- IdnMapping.cs
- SizeConverter.cs
- LiteralControl.cs
- Command.cs
- IDReferencePropertyAttribute.cs
- StylusTip.cs
- CreateDataSourceDialog.cs
- MailWebEventProvider.cs
- DataSetUtil.cs
- PinnedBufferMemoryStream.cs
- Stylesheet.cs
- XmlSchemaSimpleContentRestriction.cs
- ConfigXmlReader.cs
- ResourceDictionary.cs
- FtpRequestCacheValidator.cs
- BoundsDrawingContextWalker.cs
- Transform.cs
- HttpListener.cs
- TaskHelper.cs
- UnsafeNativeMethods.cs
- CannotUnloadAppDomainException.cs
- CommandTreeTypeHelper.cs
- DataSourceCacheDurationConverter.cs
- GroupItem.cs
- NavigationCommands.cs
- wgx_commands.cs
- EnumCodeDomSerializer.cs
- httpserverutility.cs
- GridViewUpdateEventArgs.cs
- TypeDescriptionProviderAttribute.cs
- CodeIterationStatement.cs
- PropertyManager.cs
- XsltLoader.cs
- NotifyInputEventArgs.cs
- ZeroOpNode.cs
- ListViewUpdatedEventArgs.cs
- PowerModeChangedEventArgs.cs
- FactoryGenerator.cs
- XsltFunctions.cs
- StylusButtonCollection.cs
- ParseElement.cs
- PathSegment.cs
- IdleTimeoutMonitor.cs
- __TransparentProxy.cs
- AutomationEvent.cs
- CodeCompiler.cs
- OracleRowUpdatingEventArgs.cs
- ExceptionHandler.cs
- ButtonFlatAdapter.cs
- TypeContext.cs
- SqlTriggerAttribute.cs
- StyleXamlParser.cs
- DataGridColumnHeaderCollection.cs
- WindowsTreeView.cs
- ValidatingCollection.cs
- DefaultValueAttribute.cs
- MethodBody.cs
- TextSchema.cs