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
- XmlMemberMapping.cs
- GradientStopCollection.cs
- BevelBitmapEffect.cs
- KoreanLunisolarCalendar.cs
- DirectoryInfo.cs
- ObjectContext.cs
- CodeDefaultValueExpression.cs
- XmlElement.cs
- TargetPerspective.cs
- HttpSessionStateBase.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- ContextBase.cs
- XmlSchemaType.cs
- Marshal.cs
- ContractUtils.cs
- DateTimeFormat.cs
- HtmlButton.cs
- PolyLineSegmentFigureLogic.cs
- SplashScreen.cs
- ItemsPresenter.cs
- PeerName.cs
- MasterPageParser.cs
- SqlConnectionPoolGroupProviderInfo.cs
- DataServiceProviderWrapper.cs
- PrincipalPermission.cs
- ReflectEventDescriptor.cs
- ProgressBar.cs
- Storyboard.cs
- VectorCollectionConverter.cs
- SrgsItemList.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- TextTreeInsertUndoUnit.cs
- DescendantQuery.cs
- TracingConnectionInitiator.cs
- Size3DConverter.cs
- TextEncodedRawTextWriter.cs
- HttpPostedFile.cs
- RetrieveVirtualItemEventArgs.cs
- COM2ComponentEditor.cs
- Double.cs
- initElementDictionary.cs
- DateRangeEvent.cs
- Point.cs
- MergeFilterQuery.cs
- TimeoutException.cs
- UnhandledExceptionEventArgs.cs
- RegistryDataKey.cs
- ResourceContainer.cs
- AbsoluteQuery.cs
- SecurityPolicySection.cs
- UserControlBuildProvider.cs
- ApplicationActivator.cs
- SkinIDTypeConverter.cs
- DataRowView.cs
- XmlNamespaceDeclarationsAttribute.cs
- NullRuntimeConfig.cs
- ConfigurationLocationCollection.cs
- ToolStripButton.cs
- CookieParameter.cs
- UserControlCodeDomTreeGenerator.cs
- WindowsListViewGroup.cs
- BinaryUtilClasses.cs
- KnownTypesHelper.cs
- UncommonField.cs
- HttpInputStream.cs
- HttpResponse.cs
- RefreshEventArgs.cs
- WebPartConnectionsCloseVerb.cs
- DesignerCommandSet.cs
- PngBitmapDecoder.cs
- RenamedEventArgs.cs
- RequestContextBase.cs
- XmlCharCheckingReader.cs
- XmlWellformedWriter.cs
- ResourceDictionaryCollection.cs
- GridViewDeleteEventArgs.cs
- ModelServiceImpl.cs
- HostingMessageProperty.cs
- XmlSchemaCompilationSettings.cs
- Gdiplus.cs
- SqlClientPermission.cs
- ClientBuildManagerCallback.cs
- PageTheme.cs
- SafeArrayRankMismatchException.cs
- DirtyTextRange.cs
- ParentUndoUnit.cs
- Exceptions.cs
- DbConnectionPoolGroup.cs
- ToolboxItemLoader.cs
- QuaternionAnimationBase.cs
- prefixendpointaddressmessagefilter.cs
- DrawingState.cs
- _Events.cs
- NameSpaceEvent.cs
- CloudCollection.cs
- ListBindingConverter.cs
- Choices.cs
- Transactions.cs
- MenuItemAutomationPeer.cs
- DropSource.cs