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; ////// /// public abstract class XmlResolver { ///Resolves external XML resources named by a Uniform /// Resource Identifier (URI). This class is ////// . /// /// public abstract Object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn); ///Maps a /// URI to an Object containing the actual resource. ////// /// #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. //------------------------------------------------------------------------------ //[To be supplied.] ///// 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; ////// /// public abstract class XmlResolver { ///Resolves external XML resources named by a Uniform /// Resource Identifier (URI). This class is ////// . /// /// public abstract Object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn); ///Maps a /// URI to an Object containing the actual resource. ////// /// #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.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlSignificantWhitespace.cs
- MimeReflector.cs
- ImageInfo.cs
- InputLanguageCollection.cs
- HttpCapabilitiesSectionHandler.cs
- AnnotationComponentChooser.cs
- CodeSnippetTypeMember.cs
- Pair.cs
- WeakEventTable.cs
- RangeContentEnumerator.cs
- ToolStripSeparatorRenderEventArgs.cs
- StyleCollection.cs
- CompareValidator.cs
- StaticDataManager.cs
- recordstatefactory.cs
- Console.cs
- CardSpaceException.cs
- HashLookup.cs
- PeerApplication.cs
- RectIndependentAnimationStorage.cs
- BufferedReadStream.cs
- AssociationProvider.cs
- IdleTimeoutMonitor.cs
- HandlerWithFactory.cs
- VectorAnimationUsingKeyFrames.cs
- EditorPartCollection.cs
- ListItemCollection.cs
- PhoneCall.cs
- RemotingException.cs
- FaultCode.cs
- BooleanExpr.cs
- DataServiceQueryProvider.cs
- SoapWriter.cs
- CompilerErrorCollection.cs
- TextFormatterHost.cs
- DataServiceQuery.cs
- QilLiteral.cs
- LocatorManager.cs
- log.cs
- SafeHandles.cs
- ParameterCollection.cs
- Boolean.cs
- TextRunCache.cs
- SettingsSavedEventArgs.cs
- ToolStripControlHost.cs
- SelectionItemPatternIdentifiers.cs
- FlowDocumentPage.cs
- FixedSOMTableRow.cs
- AccessDataSource.cs
- TypeExtensionConverter.cs
- ErrorProvider.cs
- ResourcePool.cs
- SecurityTokenAuthenticator.cs
- ClientScriptManager.cs
- ItemChangedEventArgs.cs
- PropertyMapper.cs
- CheckBoxRenderer.cs
- ImageClickEventArgs.cs
- ParsedAttributeCollection.cs
- OdbcConnectionFactory.cs
- SelectionHighlightInfo.cs
- LoadedEvent.cs
- SessionSymmetricTransportSecurityProtocolFactory.cs
- TableCell.cs
- ListControlStringCollectionEditor.cs
- GridView.cs
- MetaModel.cs
- EntityProviderServices.cs
- StubHelpers.cs
- FormsAuthenticationTicket.cs
- IResourceProvider.cs
- EntityContainerEntitySet.cs
- BookmarkTable.cs
- CustomAttributeFormatException.cs
- Polygon.cs
- SqlDataAdapter.cs
- BitmapEncoder.cs
- DeclaredTypeValidator.cs
- DataServiceHost.cs
- ContentHostHelper.cs
- ConfigViewGenerator.cs
- PipeStream.cs
- CheckBox.cs
- _NetworkingPerfCounters.cs
- ApplicationSettingsBase.cs
- EdmTypeAttribute.cs
- JoinTreeNode.cs
- AddInBase.cs
- DataSourceExpression.cs
- TextTreeTextElementNode.cs
- SchemaCollectionPreprocessor.cs
- CellQuery.cs
- LambdaCompiler.Expressions.cs
- UpdateException.cs
- FacetValueContainer.cs
- ExitEventArgs.cs
- ApplicationManager.cs
- XmlSchemaImport.cs
- TouchPoint.cs
- MethodRental.cs