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
- CompilationUtil.cs
- SubtreeProcessor.cs
- DateTimeFormat.cs
- _NetRes.cs
- MulticastIPAddressInformationCollection.cs
- MimeObjectFactory.cs
- Formatter.cs
- BooleanConverter.cs
- UnmanagedMemoryStreamWrapper.cs
- ActiveXHelper.cs
- BindableAttribute.cs
- XmlParser.cs
- Fault.cs
- EntityDescriptor.cs
- SessionChannels.cs
- WinEventQueueItem.cs
- BezierSegment.cs
- TdsParserSessionPool.cs
- JapaneseLunisolarCalendar.cs
- OciHandle.cs
- CodeExporter.cs
- ContentElement.cs
- ParamArrayAttribute.cs
- AsnEncodedData.cs
- NoClickablePointException.cs
- HttpWebResponse.cs
- FloatSumAggregationOperator.cs
- ImageButton.cs
- KeyboardNavigation.cs
- SqlRowUpdatedEvent.cs
- OdbcTransaction.cs
- IdentityManager.cs
- UIAgentAsyncEndRequest.cs
- ServicePointManagerElement.cs
- IfJoinedCondition.cs
- BindingExpressionUncommonField.cs
- QuaternionRotation3D.cs
- SafeHandles.cs
- ColorEditor.cs
- StickyNoteHelper.cs
- RectangleConverter.cs
- EntityDataSourceEntityTypeFilterItem.cs
- DefaultWorkflowSchedulerService.cs
- Missing.cs
- ClientFactory.cs
- BinaryFormatter.cs
- AggregateNode.cs
- WebPartManager.cs
- ObjectReferenceStack.cs
- AdornerDecorator.cs
- StorageAssociationSetMapping.cs
- DrawingContext.cs
- ToolStripProgressBar.cs
- XmlEntity.cs
- DetailsViewUpdateEventArgs.cs
- RemoveStoryboard.cs
- SyndicationDeserializer.cs
- ResourceSet.cs
- Parser.cs
- Mutex.cs
- DuplicateDetector.cs
- HwndHostAutomationPeer.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ComponentResourceManager.cs
- StringHandle.cs
- SqlBuilder.cs
- FrameworkElementFactory.cs
- BooleanFunctions.cs
- DataSet.cs
- ScrollViewer.cs
- TemplateComponentConnector.cs
- LiteralControl.cs
- WebPartConnectionsCancelEventArgs.cs
- SurrogateEncoder.cs
- QueryableFilterUserControl.cs
- ElementMarkupObject.cs
- StickyNoteAnnotations.cs
- ToolStripItemEventArgs.cs
- OrderPreservingPipeliningSpoolingTask.cs
- Graphics.cs
- NativeWindow.cs
- LazyTextWriterCreator.cs
- ClientTargetCollection.cs
- PageHandlerFactory.cs
- DataControlPagerLinkButton.cs
- AttachedPropertyMethodSelector.cs
- Viewport3DVisual.cs
- GB18030Encoding.cs
- DbConnectionOptions.cs
- RegexStringValidator.cs
- DtdParser.cs
- MaskedTextBoxTextEditor.cs
- _TransmitFileOverlappedAsyncResult.cs
- PrivacyNoticeBindingElementImporter.cs
- MetadataFile.cs
- assemblycache.cs
- Menu.cs
- Vector3DAnimationBase.cs
- GeneralTransformGroup.cs
- PassportIdentity.cs