Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / XmlResolver.cs / 1305376 / XmlResolver.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml
{
using System;
using System.IO;
using System.Text;
using System.Security;
using System.Security.Permissions;
#if !SILVERLIGHT
using System.Net;
#endif
using System.Runtime.Versioning;
///
///
/// Resolves external XML resources named by a Uniform
/// Resource Identifier (URI). This class is
/// .
///
public abstract class XmlResolver {
///
///
/// Maps a
/// URI to an Object containing the actual resource.
///
public abstract Object GetEntity(Uri absoluteUri,
string role,
Type ofObjectToReturn);
///
///
/// [To be supplied.]
///
#if !SILVERLIGHT
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
#endif
public virtual Uri ResolveUri(Uri baseUri, string relativeUri) {
if ( baseUri == null || ( !baseUri.IsAbsoluteUri && baseUri.OriginalString.Length == 0 ) ) {
Uri uri = new Uri( relativeUri, UriKind.RelativeOrAbsolute );
#if !SILVERLIGHT // Path.GetFullPath is SecurityCritical
if ( !uri.IsAbsoluteUri && uri.OriginalString.Length > 0 ) {
uri = new Uri( Path.GetFullPath( relativeUri ) );
}
#endif
return uri;
}
else {
if (relativeUri == null || relativeUri.Length == 0) {
return baseUri;
}
// relative base Uri
if ( !baseUri.IsAbsoluteUri ) {
#if SILVERLIGHT
// create temporary base for the relative URIs
Uri tmpBaseUri = new Uri("tmp:///");
// create absolute base URI with the temporary base
Uri absBaseUri = new Uri(tmpBaseUri, baseUri.OriginalString);
// resolve the relative Uri into a new absolute URI
Uri resolvedAbsUri = new Uri(absBaseUri, relativeUri);
// make it relative by removing temporary base
Uri resolvedRelUri = tmpBaseUri.MakeRelativeUri(resolvedAbsUri);
return resolvedRelUri;
#else
throw new NotSupportedException(Res.GetString(Res.Xml_RelativeUriNotSupported));
#endif
}
return new Uri( baseUri, relativeUri );
}
}
#if !SILVERLIGHT
//UE attension
///
///
/// [To be supplied.]
///
public abstract ICredentials Credentials {
set;
}
#endif
public virtual bool SupportsType(Uri absoluteUri, Type type) {
if (absoluteUri == null) {
throw new ArgumentNullException("absoluteUri");
}
if (type == null || type == typeof(Stream)) {
return true;
}
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml
{
using System;
using System.IO;
using System.Text;
using System.Security;
using System.Security.Permissions;
#if !SILVERLIGHT
using System.Net;
#endif
using System.Runtime.Versioning;
///
///
/// Resolves external XML resources named by a Uniform
/// Resource Identifier (URI). This class is
/// .
///
public abstract class XmlResolver {
///
///
/// Maps a
/// URI to an Object containing the actual resource.
///
public abstract Object GetEntity(Uri absoluteUri,
string role,
Type ofObjectToReturn);
///
///
/// [To be supplied.]
///
#if !SILVERLIGHT
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
#endif
public virtual Uri ResolveUri(Uri baseUri, string relativeUri) {
if ( baseUri == null || ( !baseUri.IsAbsoluteUri && baseUri.OriginalString.Length == 0 ) ) {
Uri uri = new Uri( relativeUri, UriKind.RelativeOrAbsolute );
#if !SILVERLIGHT // Path.GetFullPath is SecurityCritical
if ( !uri.IsAbsoluteUri && uri.OriginalString.Length > 0 ) {
uri = new Uri( Path.GetFullPath( relativeUri ) );
}
#endif
return uri;
}
else {
if (relativeUri == null || relativeUri.Length == 0) {
return baseUri;
}
// relative base Uri
if ( !baseUri.IsAbsoluteUri ) {
#if SILVERLIGHT
// create temporary base for the relative URIs
Uri tmpBaseUri = new Uri("tmp:///");
// create absolute base URI with the temporary base
Uri absBaseUri = new Uri(tmpBaseUri, baseUri.OriginalString);
// resolve the relative Uri into a new absolute URI
Uri resolvedAbsUri = new Uri(absBaseUri, relativeUri);
// make it relative by removing temporary base
Uri resolvedRelUri = tmpBaseUri.MakeRelativeUri(resolvedAbsUri);
return resolvedRelUri;
#else
throw new NotSupportedException(Res.GetString(Res.Xml_RelativeUriNotSupported));
#endif
}
return new Uri( baseUri, relativeUri );
}
}
#if !SILVERLIGHT
//UE attension
///
///
/// [To be supplied.]
///
public abstract ICredentials Credentials {
set;
}
#endif
public virtual bool SupportsType(Uri absoluteUri, Type type) {
if (absoluteUri == null) {
throw new ArgumentNullException("absoluteUri");
}
if (type == null || type == typeof(Stream)) {
return true;
}
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FontSizeConverter.cs
- _SafeNetHandles.cs
- EtwProvider.cs
- Typeface.cs
- DurationConverter.cs
- MenuItemBinding.cs
- UnsettableComboBox.cs
- XmlWriterSettings.cs
- DataBinder.cs
- SecurityException.cs
- IProducerConsumerCollection.cs
- ObjRef.cs
- SplineKeyFrames.cs
- DataControlField.cs
- UiaCoreTypesApi.cs
- FactoryGenerator.cs
- TrustManagerMoreInformation.cs
- unitconverter.cs
- XmlSerializationGeneratedCode.cs
- SoapReflectionImporter.cs
- unitconverter.cs
- ObjectHandle.cs
- ServiceManagerHandle.cs
- WhitespaceRule.cs
- PriorityItem.cs
- RemoteWebConfigurationHost.cs
- PropertyToken.cs
- PropertyChangedEventArgs.cs
- MonthChangedEventArgs.cs
- PenThreadPool.cs
- RtfControls.cs
- Parameter.cs
- SqlRecordBuffer.cs
- DataColumn.cs
- QueryCacheEntry.cs
- Delegate.cs
- ReflectPropertyDescriptor.cs
- StagingAreaInputItem.cs
- UInt32Converter.cs
- MembershipSection.cs
- Ops.cs
- BamlLocalizer.cs
- ProfileGroupSettings.cs
- LinkUtilities.cs
- MetadataCache.cs
- XamlReader.cs
- x509store.cs
- WebPartTransformerCollection.cs
- EventMappingSettingsCollection.cs
- TreeViewEvent.cs
- SafeNativeMethods.cs
- TrackingSection.cs
- XmlDomTextWriter.cs
- AnnotationMap.cs
- RoleManagerModule.cs
- OrCondition.cs
- QueryResults.cs
- TimestampInformation.cs
- MonikerUtility.cs
- CngKeyCreationParameters.cs
- ArraySortHelper.cs
- EditorReuseAttribute.cs
- FontInfo.cs
- _ProxyChain.cs
- SiteMapDataSourceView.cs
- SoapIgnoreAttribute.cs
- SystemWebSectionGroup.cs
- BaseHashHelper.cs
- SecurityException.cs
- ConnectionConsumerAttribute.cs
- ConsoleCancelEventArgs.cs
- WebPartDisplayModeCollection.cs
- LocatorGroup.cs
- PlaceHolder.cs
- DataGridToolTip.cs
- SqlSupersetValidator.cs
- EntityContainer.cs
- PrintControllerWithStatusDialog.cs
- ConnectionInterfaceCollection.cs
- WebPartDescription.cs
- ThreadStaticAttribute.cs
- QuotedPrintableStream.cs
- FontNamesConverter.cs
- IssuanceTokenProviderBase.cs
- ReadOnlyDictionary.cs
- XPathDocument.cs
- LexicalChunk.cs
- ConfigurationStrings.cs
- EventLogPermissionAttribute.cs
- DataViewSetting.cs
- RootBrowserWindowAutomationPeer.cs
- LocalBuilder.cs
- TemplateControlParser.cs
- brushes.cs
- EntityDesignerUtils.cs
- TreeViewEvent.cs
- XmlElementAttributes.cs
- Int32Animation.cs
- VScrollProperties.cs
- TypedTableGenerator.cs