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
- KeyBinding.cs
- HtmlEmptyTagControlBuilder.cs
- CmsInterop.cs
- ClientSettingsProvider.cs
- MailAddressCollection.cs
- ObjectCloneHelper.cs
- KnownBoxes.cs
- WindowsScroll.cs
- DocumentGrid.cs
- PageHandlerFactory.cs
- CultureInfoConverter.cs
- SpecularMaterial.cs
- HttpPostProtocolReflector.cs
- EntityDataSourceChangedEventArgs.cs
- PagedDataSource.cs
- AnimationClockResource.cs
- SQLDateTimeStorage.cs
- CheckBoxField.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- SR.cs
- StateValidator.cs
- RemoveStoryboard.cs
- NullableDecimalSumAggregationOperator.cs
- CqlQuery.cs
- DateBoldEvent.cs
- StructureChangedEventArgs.cs
- IsolatedStorageFilePermission.cs
- AuthenticationSchemesHelper.cs
- StylusLogic.cs
- sqlmetadatafactory.cs
- ExtensionDataObject.cs
- StylusShape.cs
- EventsTab.cs
- __ConsoleStream.cs
- RoutedPropertyChangedEventArgs.cs
- TraceLog.cs
- QilReplaceVisitor.cs
- QuarticEase.cs
- Expressions.cs
- Property.cs
- StyleBamlRecordReader.cs
- MediaSystem.cs
- Models.cs
- PeerContact.cs
- AuthorizationRuleCollection.cs
- Underline.cs
- PolyBezierSegment.cs
- _FtpControlStream.cs
- ValueQuery.cs
- DataTableTypeConverter.cs
- PriorityBindingExpression.cs
- streamingZipPartStream.cs
- PassportPrincipal.cs
- InputLanguageEventArgs.cs
- IndexedEnumerable.cs
- ToolStripContentPanelRenderEventArgs.cs
- RecipientInfo.cs
- SiteMapDataSource.cs
- GeometryDrawing.cs
- WebHostUnsafeNativeMethods.cs
- TreeViewItem.cs
- MethodCallTranslator.cs
- PointAnimationClockResource.cs
- DesignerVerbCollection.cs
- XmlQualifiedName.cs
- MainMenu.cs
- PropertyHelper.cs
- XsltQilFactory.cs
- DropShadowEffect.cs
- GroupBoxAutomationPeer.cs
- HttpCookie.cs
- GlyphsSerializer.cs
- TextRunTypographyProperties.cs
- XslException.cs
- Empty.cs
- MethodToken.cs
- SoapObjectWriter.cs
- DetailsViewRow.cs
- ScriptMethodAttribute.cs
- ColorAnimationBase.cs
- ArgumentValue.cs
- XmlDocumentSerializer.cs
- ViewStateModeByIdAttribute.cs
- ComponentResourceManager.cs
- PrintDialogException.cs
- Stack.cs
- ContextQuery.cs
- ByteAnimationBase.cs
- MergeEnumerator.cs
- StsCommunicationException.cs
- PropertyEmitter.cs
- Executor.cs
- BaseAsyncResult.cs
- unsafeIndexingFilterStream.cs
- SecurityPermission.cs
- UseAttributeSetsAction.cs
- XmlHierarchicalDataSourceView.cs
- BaseDataBoundControlDesigner.cs
- DataSourceCacheDurationConverter.cs
- CounterSample.cs