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
- MiniLockedBorderGlyph.cs
- HMACSHA512.cs
- IncrementalReadDecoders.cs
- _SafeNetHandles.cs
- OperandQuery.cs
- EntityClientCacheKey.cs
- ProfileBuildProvider.cs
- OdbcEnvironmentHandle.cs
- KnowledgeBase.cs
- PointCollection.cs
- BevelBitmapEffect.cs
- BaseUriHelper.cs
- TextElement.cs
- XmlSerializerAssemblyAttribute.cs
- StateItem.cs
- XXXOnTypeBuilderInstantiation.cs
- IIS7WorkerRequest.cs
- OleDbMetaDataFactory.cs
- PageBreakRecord.cs
- Tablet.cs
- ControlCachePolicy.cs
- DesignConnection.cs
- ScrollContentPresenter.cs
- ReferenceConverter.cs
- ObjectSecurity.cs
- BoundingRectTracker.cs
- EntityContainerRelationshipSetEnd.cs
- SqlCommand.cs
- SqlDataSourceSelectingEventArgs.cs
- ProcessManager.cs
- TextureBrush.cs
- ApplicationException.cs
- IgnoreSectionHandler.cs
- Baml6Assembly.cs
- HttpApplication.cs
- Size3D.cs
- ComNativeDescriptor.cs
- PropertyConverter.cs
- ToolStripArrowRenderEventArgs.cs
- CapabilitiesAssignment.cs
- KeyedCollection.cs
- Stroke2.cs
- SymLanguageVendor.cs
- SrgsNameValueTag.cs
- MenuStrip.cs
- ConnectionStringsExpressionBuilder.cs
- ComponentEditorPage.cs
- ThreadNeutralSemaphore.cs
- AbstractSvcMapFileLoader.cs
- ImageMapEventArgs.cs
- DependencyObjectCodeDomSerializer.cs
- base64Transforms.cs
- UnsafeMethods.cs
- ThrowHelper.cs
- OleDbInfoMessageEvent.cs
- GetIsBrowserClientRequest.cs
- EditableLabelControl.cs
- IDReferencePropertyAttribute.cs
- GPPOINT.cs
- Attribute.cs
- RadialGradientBrush.cs
- BlurEffect.cs
- BoundColumn.cs
- PostBackOptions.cs
- BitmapEffectDrawingContextState.cs
- IISUnsafeMethods.cs
- FindCriteriaApril2005.cs
- DataSourceHelper.cs
- CompModSwitches.cs
- BaseValidator.cs
- ComboBox.cs
- ParseHttpDate.cs
- Geometry.cs
- BooleanFunctions.cs
- Size3D.cs
- LineServicesCallbacks.cs
- Screen.cs
- mda.cs
- RelatedEnd.cs
- FormsAuthenticationTicket.cs
- CodeSpit.cs
- ConfigurationSectionCollection.cs
- AssociationTypeEmitter.cs
- TypeSystemProvider.cs
- PersistChildrenAttribute.cs
- ObjectDisposedException.cs
- DocumentAutomationPeer.cs
- DeflateStream.cs
- MobileCategoryAttribute.cs
- XmlDownloadManager.cs
- CharEntityEncoderFallback.cs
- DataPager.cs
- DPTypeDescriptorContext.cs
- ResolveDuplexAsyncResult.cs
- View.cs
- TypedTableBase.cs
- XmlAttributeOverrides.cs
- Pool.cs
- CompatibleComparer.cs
- ExpressionNormalizer.cs