Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / Xml / System / Xml / Serialization / Configuration / XmlSerializerSection.cs / 3 / XmlSerializerSection.cs
// 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 ( 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PanningMessageFilter.cs
- SapiRecoContext.cs
- Mouse.cs
- WindowsGrip.cs
- MetadataCollection.cs
- PrimitiveXmlSerializers.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- SafeMILHandle.cs
- UidManager.cs
- OleDbEnumerator.cs
- RenderContext.cs
- LongTypeConverter.cs
- OracleFactory.cs
- BlurBitmapEffect.cs
- MouseBinding.cs
- DataRowCollection.cs
- ToolstripProfessionalRenderer.cs
- CompositeDuplexElement.cs
- TextRunCache.cs
- Tool.cs
- SoapSchemaExporter.cs
- Shape.cs
- CustomLineCap.cs
- MemoryMappedViewStream.cs
- RolePrincipal.cs
- EventLogLink.cs
- HtmlShimManager.cs
- SqlStatistics.cs
- TemplateAction.cs
- StoreAnnotationsMap.cs
- ImageAutomationPeer.cs
- PageBuildProvider.cs
- WebHttpElement.cs
- WindowsIPAddress.cs
- MetadataUtil.cs
- DataMemberConverter.cs
- PeerFlooder.cs
- GridViewCellAutomationPeer.cs
- OwnerDrawPropertyBag.cs
- PictureBoxDesigner.cs
- SqlErrorCollection.cs
- FilterElement.cs
- LookupBindingPropertiesAttribute.cs
- sortedlist.cs
- Glyph.cs
- DataViewListener.cs
- DoubleAnimationUsingKeyFrames.cs
- ReceiveSecurityHeaderEntry.cs
- FormViewCommandEventArgs.cs
- RegularExpressionValidator.cs
- WMIInterop.cs
- AssemblyContextControlItem.cs
- DrawingServices.cs
- SerializationInfo.cs
- InlineCollection.cs
- ThreadInterruptedException.cs
- CapabilitiesUse.cs
- DesignTimeTemplateParser.cs
- ImageFormatConverter.cs
- StreamSecurityUpgradeAcceptorAsyncResult.cs
- SignHashRequest.cs
- FormViewPageEventArgs.cs
- Operator.cs
- DataGridTextBoxColumn.cs
- RsaKeyIdentifierClause.cs
- HtmlButton.cs
- SqlRecordBuffer.cs
- HttpResponseHeader.cs
- TemplateBindingExtension.cs
- SHA1.cs
- CodeExpressionCollection.cs
- BindingCollection.cs
- OleDbRowUpdatingEvent.cs
- SiteMapNodeItemEventArgs.cs
- ControlCachePolicy.cs
- DefaultValueConverter.cs
- HandleCollector.cs
- SiteMapNodeItemEventArgs.cs
- IPAddressCollection.cs
- LinearGradientBrush.cs
- BitmapCodecInfo.cs
- Pkcs7Recipient.cs
- _DigestClient.cs
- Color.cs
- MediaSystem.cs
- CreateParams.cs
- ShortcutKeysEditor.cs
- SingleKeyFrameCollection.cs
- DataSourceHelper.cs
- PerformanceCounterPermission.cs
- EditingCommands.cs
- SEHException.cs
- ColorConvertedBitmap.cs
- DesignerActionKeyboardBehavior.cs
- DesignRelationCollection.cs
- TaskForm.cs
- ReflectionUtil.cs
- HtmlTable.cs
- Binding.cs
- CompiledELinqQueryState.cs