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
- CqlIdentifiers.cs
- GeneralTransform3DGroup.cs
- PrimarySelectionAdorner.cs
- NotifyParentPropertyAttribute.cs
- mediaeventshelper.cs
- AdjustableArrowCap.cs
- HttpCachePolicy.cs
- TypeSystemProvider.cs
- ModelUIElement3D.cs
- DuplicateWaitObjectException.cs
- KnownTypes.cs
- SafeRightsManagementPubHandle.cs
- CompiledQueryCacheKey.cs
- WindowsServiceElement.cs
- StandardCommandToolStripMenuItem.cs
- SQLResource.cs
- TemplateContent.cs
- SoapFault.cs
- OptimalBreakSession.cs
- XmlWriterTraceListener.cs
- RectAnimationUsingKeyFrames.cs
- OperationParameterInfo.cs
- AssemblyAttributes.cs
- TextRange.cs
- safelinkcollection.cs
- LeaseManager.cs
- TreeViewItemAutomationPeer.cs
- StateItem.cs
- CodeNamespace.cs
- SelectionItemProviderWrapper.cs
- Point3D.cs
- DbParameterCollection.cs
- SQLDecimalStorage.cs
- ArraySet.cs
- Rectangle.cs
- Helper.cs
- StringResourceManager.cs
- SpeechEvent.cs
- ContractInstanceProvider.cs
- ServiceDeploymentInfo.cs
- XMLUtil.cs
- TransformPattern.cs
- FillRuleValidation.cs
- WebPartDisplayModeEventArgs.cs
- HtmlShim.cs
- WindowsMenu.cs
- MouseGestureConverter.cs
- MenuItemCollectionEditor.cs
- SqlLiftIndependentRowExpressions.cs
- GeometryCollection.cs
- DataGridTable.cs
- IpcClientChannel.cs
- DelayedRegex.cs
- RootNamespaceAttribute.cs
- PlatformNotSupportedException.cs
- StringDictionaryCodeDomSerializer.cs
- SHA256Managed.cs
- InputProviderSite.cs
- Hex.cs
- RuntimeArgumentHandle.cs
- FocusWithinProperty.cs
- ReadOnlyHierarchicalDataSourceView.cs
- SqlCommandSet.cs
- KnownTypesProvider.cs
- MessageDroppedTraceRecord.cs
- EntityContainerEntitySet.cs
- MarshalDirectiveException.cs
- StylusPointProperty.cs
- SqlDataSourceSelectingEventArgs.cs
- PluralizationServiceUtil.cs
- DebuggerAttributes.cs
- SoapConverter.cs
- GradientSpreadMethodValidation.cs
- WebPartDisplayModeCancelEventArgs.cs
- UIElement3D.cs
- RTLAwareMessageBox.cs
- WebPartMovingEventArgs.cs
- Win32PrintDialog.cs
- ConfigurationSectionCollection.cs
- CSharpCodeProvider.cs
- OleDbReferenceCollection.cs
- ListSortDescriptionCollection.cs
- TiffBitmapDecoder.cs
- PreviewPrintController.cs
- ClassHandlersStore.cs
- MessageDecoder.cs
- cookie.cs
- StructuredTypeInfo.cs
- OleDbConnectionInternal.cs
- DecimalConverter.cs
- FileDialogPermission.cs
- SQLSingle.cs
- QueueProcessor.cs
- SafeRightsManagementEnvironmentHandle.cs
- XsdBuildProvider.cs
- LookupNode.cs
- ListViewGroup.cs
- InlineCollection.cs
- GACMembershipCondition.cs
- LogEntryUtils.cs