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
- HttpBrowserCapabilitiesWrapper.cs
- RemoteWebConfigurationHost.cs
- EdmEntityTypeAttribute.cs
- StatusBarAutomationPeer.cs
- OrthographicCamera.cs
- Timer.cs
- EncryptedKeyHashIdentifierClause.cs
- CacheDependency.cs
- ACL.cs
- BookmarkWorkItem.cs
- TypeForwardedToAttribute.cs
- DockPattern.cs
- BypassElementCollection.cs
- MergeExecutor.cs
- XmlSchemaException.cs
- CloudCollection.cs
- SqlFlattener.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- CalculatedColumn.cs
- Matrix.cs
- DataRow.cs
- ColumnReorderedEventArgs.cs
- Canvas.cs
- DrawingContextDrawingContextWalker.cs
- GraphicsPath.cs
- SqlRecordBuffer.cs
- DateTime.cs
- RadioButton.cs
- ContractsBCL.cs
- GenerateTemporaryTargetAssembly.cs
- Rijndael.cs
- WebPartEditorOkVerb.cs
- InputProcessorProfiles.cs
- httpapplicationstate.cs
- AlphaSortedEnumConverter.cs
- HostElement.cs
- SmiMetaData.cs
- EtwTrace.cs
- PeekCompletedEventArgs.cs
- DataGridViewRow.cs
- ReferenceEqualityComparer.cs
- XPathNode.cs
- XmlReaderSettings.cs
- DbMetaDataFactory.cs
- XmlCharCheckingWriter.cs
- ImpersonateTokenRef.cs
- ViewKeyConstraint.cs
- ColorConverter.cs
- ReflectionPermission.cs
- FirstQueryOperator.cs
- ControlPager.cs
- Validator.cs
- SID.cs
- ChunkedMemoryStream.cs
- GeneratedCodeAttribute.cs
- CultureInfoConverter.cs
- XmlSerializerNamespaces.cs
- TextPenaltyModule.cs
- ToolStripDropDownClosingEventArgs.cs
- CellCreator.cs
- SetStateEventArgs.cs
- SecurityRequiresReviewAttribute.cs
- ISSmlParser.cs
- ExpressionStringBuilder.cs
- RoleManagerSection.cs
- ServicePerformanceCounters.cs
- ServiceDiscoveryBehavior.cs
- DesignerHelpers.cs
- FontClient.cs
- RegexRunner.cs
- PhysicalFontFamily.cs
- DragEventArgs.cs
- SerialStream.cs
- BindableAttribute.cs
- Attributes.cs
- ScrollChrome.cs
- GridViewEditEventArgs.cs
- XmlQueryTypeFactory.cs
- SafeNativeMethodsCLR.cs
- SqlUserDefinedTypeAttribute.cs
- QualifierSet.cs
- InkSerializer.cs
- DebugView.cs
- PropertyManager.cs
- Visitor.cs
- ScrollViewer.cs
- BitVec.cs
- ListSortDescription.cs
- GridItemCollection.cs
- MouseDevice.cs
- InstanceDescriptor.cs
- WebResponse.cs
- Collection.cs
- ProcessingInstructionAction.cs
- BindingGroup.cs
- ActivityExecutorDelegateInfo.cs
- DataGridViewCellEventArgs.cs
- IndicCharClassifier.cs
- ServicePointManager.cs
- SmiSettersStream.cs