XmlResolver.GetEntity(Uri, String, Type) 方法

定义

当在派生类中被重写时,将 URI 映射到包含实际资源的对象。When overridden in a derived class, maps a URI to an object that contains the actual resource.

public:
 abstract System::Object ^ GetEntity(Uri ^ absoluteUri, System::String ^ role, Type ^ ofObjectToReturn);
public abstract object? GetEntity (Uri absoluteUri, string? role, Type? ofObjectToReturn);
public abstract object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn);
abstract member GetEntity : Uri * string * Type -> obj
Public MustOverride Function GetEntity (absoluteUri As Uri, role As String, ofObjectToReturn As Type) As Object

参数

absoluteUri
Uri

ResolveUri(Uri, String) 返回的 URI。The URI returned from ResolveUri(Uri, String).

role
String

当前未使用。Currently not used.

ofObjectToReturn
Type

要返回的对象的类型。The type of object to return. 当前版本只返回 System.IO.Stream 对象。The current version only returns System.IO.Stream objects.

返回

Object

流对象;如果指定了流以外的类型,则为 nullA stream object or null if a type other than stream is specified.

例外

ofObjectToReturn 不是 Stream 类型。ofObjectToReturn is not a Stream type.

指定的 URI 不是一个绝对 URI。The specified URI is not an absolute URI.

absoluteUrinullabsoluteUri is null.

存在运行时错误(例如中断的服务器连接)。There is a runtime error (for example, an interrupted server connection).

示例

XmlUrlResolver.GetEntity有关使用此方法的示例,请参阅。See XmlUrlResolver.GetEntity for an example using this method.

注解

如果调用方想要将给定的 URI 映射到包含 URI 表示的实际资源的对象,则使用此方法。This method is used when the caller wants to map a given URI into the object containing the actual resource that the URI represents. 返回的对象类型是可转让的;但是,实现必须始终支持 System.IO.StreamThe type of object returned is negotiable; however, the implementation must always support System.IO.Stream.

有关此方法的异步版本,请参阅 GetEntityAsyncFor the asynchronous version of this method, see GetEntityAsync.

重要

应用程序可以 GetEntity 通过实现一个 IStream 限制读取的字节数的来缓解对方法的内存拒绝服务威胁。Your application can mitigate memory denial of service threats to the GetEntity method by implementing an IStream that limits the number of bytes read. 这有助于防止恶意代码尝试将无限字节流传递到方法的情况 GetEntityThis helps guard against situations where malicious code attempts to pass an infinite stream of bytes to the GetEntity method.

适用于