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
- PreviewPrintController.cs
- FigureHelper.cs
- ServiceProviders.cs
- SelectionWordBreaker.cs
- XmlSerializerFormatAttribute.cs
- MergeLocalizationDirectives.cs
- BindingExpressionBase.cs
- RightsManagementEncryptionTransform.cs
- TreeBuilder.cs
- TreeWalkHelper.cs
- GPStream.cs
- ToolStripSplitButton.cs
- IdleTimeoutMonitor.cs
- SafeEventLogWriteHandle.cs
- TimeEnumHelper.cs
- Token.cs
- util.cs
- ObjectAssociationEndMapping.cs
- FormViewUpdatedEventArgs.cs
- XmlElementAttribute.cs
- WindowsTokenRoleProvider.cs
- XmlSchemaAny.cs
- InteropExecutor.cs
- MenuItemStyle.cs
- CounterCreationData.cs
- Slider.cs
- SmtpReplyReaderFactory.cs
- CodeStatementCollection.cs
- AdornerDecorator.cs
- _SSPISessionCache.cs
- ClientBuildManager.cs
- CheckBox.cs
- DataBinder.cs
- FocusTracker.cs
- NetworkAddressChange.cs
- AesCryptoServiceProvider.cs
- ISCIIEncoding.cs
- RoleExceptions.cs
- TextBoxRenderer.cs
- PtsCache.cs
- FigureHelper.cs
- XmlCustomFormatter.cs
- CompiledRegexRunnerFactory.cs
- cache.cs
- ProtectedProviderSettings.cs
- LineBreak.cs
- PriorityChain.cs
- FilteredSchemaElementLookUpTable.cs
- Serializer.cs
- RawStylusInputReport.cs
- StateRuntime.cs
- ResolveCriteria.cs
- SkewTransform.cs
- RemoteWebConfigurationHostServer.cs
- CodeSnippetExpression.cs
- LambdaCompiler.Generated.cs
- SchemaCollectionPreprocessor.cs
- ProxyFragment.cs
- NameObjectCollectionBase.cs
- WebPartConnectionsCancelEventArgs.cs
- SplineKeyFrames.cs
- RSACryptoServiceProvider.cs
- SerializationStore.cs
- XmlSchemaDocumentation.cs
- TransformerTypeCollection.cs
- PEFileEvidenceFactory.cs
- ProfileSettingsCollection.cs
- NamespaceMapping.cs
- DataGridItemEventArgs.cs
- EntityCommandDefinition.cs
- TextSearch.cs
- StorageEntityTypeMapping.cs
- DefaultTraceListener.cs
- TickBar.cs
- TreeNodeConverter.cs
- BindingCollection.cs
- DrawingImage.cs
- QualificationDataAttribute.cs
- CapiSafeHandles.cs
- XmlSignificantWhitespace.cs
- DerivedKeySecurityTokenStub.cs
- DataBinder.cs
- NoneExcludedImageIndexConverter.cs
- UrlPropertyAttribute.cs
- ReachPageContentSerializerAsync.cs
- NetWebProxyFinder.cs
- StyleCollection.cs
- RenderData.cs
- QilXmlReader.cs
- TimeManager.cs
- XmlCDATASection.cs
- TableCell.cs
- TreeViewEvent.cs
- SystemIPAddressInformation.cs
- CustomWebEventKey.cs
- _Win32.cs
- XsdBuilder.cs
- DefaultShape.cs
- SmtpNtlmAuthenticationModule.cs
- CommandConverter.cs