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
- TypedDataSetSchemaImporterExtensionFx35.cs
- SvcMapFileSerializer.cs
- NameValueConfigurationElement.cs
- ComplexType.cs
- ImageMap.cs
- SqlDataSourceCommandEventArgs.cs
- StoreUtilities.cs
- LinearKeyFrames.cs
- ReliabilityContractAttribute.cs
- MetadataPropertyCollection.cs
- AnimationException.cs
- DataGridViewSelectedColumnCollection.cs
- PopupEventArgs.cs
- AdjustableArrowCap.cs
- XhtmlBasicCommandAdapter.cs
- XmlSerializerNamespaces.cs
- ReturnType.cs
- RelatedImageListAttribute.cs
- ConfigsHelper.cs
- EntityDataSourceChangedEventArgs.cs
- IndexedSelectQueryOperator.cs
- SafeFreeMibTable.cs
- BaseTreeIterator.cs
- PeerEndPoint.cs
- BasicBrowserDialog.cs
- XmlSchemaComplexContentExtension.cs
- HttpHandlerActionCollection.cs
- RotateTransform3D.cs
- TextTabProperties.cs
- TextStore.cs
- AlternateViewCollection.cs
- MobileCapabilities.cs
- DateTimeConstantAttribute.cs
- AdditionalEntityFunctions.cs
- StickyNoteContentControl.cs
- PageAdapter.cs
- XamlPoint3DCollectionSerializer.cs
- ScrollBar.cs
- _SecureChannel.cs
- CompilerTypeWithParams.cs
- NetworkCredential.cs
- PartialToken.cs
- ByeMessageCD1.cs
- SchemaNamespaceManager.cs
- Application.cs
- CompilationSection.cs
- DataGridViewRowsAddedEventArgs.cs
- CustomTypeDescriptor.cs
- SqlDataSourceSelectingEventArgs.cs
- NavigationWindowAutomationPeer.cs
- ProjectionCamera.cs
- SafeFileHandle.cs
- SmiTypedGetterSetter.cs
- DirectoryObjectSecurity.cs
- UnsafeNetInfoNativeMethods.cs
- OptimalBreakSession.cs
- PropertyNames.cs
- EncodingNLS.cs
- LogicalCallContext.cs
- LinkUtilities.cs
- LinkLabelLinkClickedEvent.cs
- DataErrorValidationRule.cs
- GridViewEditEventArgs.cs
- PeerMessageDispatcher.cs
- MsmqHostedTransportConfiguration.cs
- DataServiceQueryProvider.cs
- OSEnvironmentHelper.cs
- VSWCFServiceContractGenerator.cs
- MsmqAppDomainProtocolHandler.cs
- DataAdapter.cs
- CatalogZone.cs
- DbCommandDefinition.cs
- CollectionDataContract.cs
- AuthenticationSection.cs
- RectAnimation.cs
- OpenCollectionAsyncResult.cs
- ParserStreamGeometryContext.cs
- DataServiceRequestArgs.cs
- CornerRadiusConverter.cs
- ParameterCollectionEditor.cs
- PolicyUnit.cs
- ThreadStaticAttribute.cs
- TextParagraphView.cs
- NotSupportedException.cs
- NamespaceInfo.cs
- Int32AnimationBase.cs
- ServiceDurableInstanceContextProvider.cs
- Roles.cs
- Type.cs
- SiteIdentityPermission.cs
- StylusCollection.cs
- HTTPNotFoundHandler.cs
- GroupJoinQueryOperator.cs
- TreeViewAutomationPeer.cs
- ContractUtils.cs
- RemotingException.cs
- ActivityDesigner.cs
- ScrollChrome.cs
- NativeObjectSecurity.cs
- DbConnectionStringCommon.cs