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
- MultiAsyncResult.cs
- IList.cs
- Overlapped.cs
- PerfCounters.cs
- CoTaskMemHandle.cs
- FieldNameLookup.cs
- RectangleHotSpot.cs
- Stroke.cs
- ValueQuery.cs
- RemoveStoryboard.cs
- SqlParameter.cs
- FragmentQuery.cs
- ConsoleKeyInfo.cs
- FindCriteria.cs
- DataGridTableCollection.cs
- RelationshipEndCollection.cs
- Lease.cs
- Convert.cs
- XmlAnyElementAttributes.cs
- IriParsingElement.cs
- AxisAngleRotation3D.cs
- CustomAttribute.cs
- Vector3DConverter.cs
- XpsColorContext.cs
- XmlDocumentFragment.cs
- StringUtil.cs
- BinaryObjectInfo.cs
- AnimationLayer.cs
- RemoveStoryboard.cs
- DbFunctionCommandTree.cs
- Point.cs
- ServicePoint.cs
- SequenceNumber.cs
- ApplicationFileCodeDomTreeGenerator.cs
- BitmapImage.cs
- Span.cs
- ProviderException.cs
- PauseStoryboard.cs
- FastEncoderWindow.cs
- Aes.cs
- Command.cs
- DataGridViewIntLinkedList.cs
- ParsedAttributeCollection.cs
- VariableDesigner.xaml.cs
- XmlMembersMapping.cs
- CommandEventArgs.cs
- DataGridViewButtonCell.cs
- DynamicDocumentPaginator.cs
- AccessDataSourceView.cs
- RuleRef.cs
- StandardTransformFactory.cs
- StickyNote.cs
- StatusBarPanel.cs
- MailMessage.cs
- ProjectedSlot.cs
- Int32KeyFrameCollection.cs
- WeakReference.cs
- DoubleCollection.cs
- DnsCache.cs
- EditorZone.cs
- ProfileBuildProvider.cs
- TextTreeDeleteContentUndoUnit.cs
- MessageDispatch.cs
- PinnedBufferMemoryStream.cs
- Thumb.cs
- LabelLiteral.cs
- HiddenField.cs
- TreeNodeCollectionEditor.cs
- ActiveXHost.cs
- oledbmetadatacolumnnames.cs
- SortAction.cs
- DetailsViewUpdateEventArgs.cs
- ParentUndoUnit.cs
- RealProxy.cs
- AutoGeneratedFieldProperties.cs
- MembershipValidatePasswordEventArgs.cs
- DataSvcMapFile.cs
- PackageController.cs
- StylusCaptureWithinProperty.cs
- EntityWithKeyStrategy.cs
- OutputScopeManager.cs
- ExtenderProvidedPropertyAttribute.cs
- CharacterBufferReference.cs
- ChangePassword.cs
- TemplateBuilder.cs
- HtmlInputPassword.cs
- LayoutTableCell.cs
- NetworkInformationException.cs
- NameValuePermission.cs
- PrintDialog.cs
- Formatter.cs
- DropTarget.cs
- BindingValueChangedEventArgs.cs
- cookiecollection.cs
- SubpageParagraph.cs
- SqlDataSourceQuery.cs
- UInt16.cs
- FocusTracker.cs
- ValidationErrorCollection.cs
- DataControlReferenceCollection.cs