XmlUrlResolver.GetEntity(Uri, String, Type) 메서드

정의

실제 리소스가 포함된 개체로 URI를 매핑합니다.

public:
 override System::Object ^ GetEntity(Uri ^ absoluteUri, System::String ^ role, Type ^ ofObjectToReturn);
public override object? GetEntity (Uri absoluteUri, string? role, Type? ofObjectToReturn);
public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn);
override this.GetEntity : Uri * string * Type -> obj
Public Overrides Function GetEntity (absoluteUri As Uri, role As String, ofObjectToReturn As Type) As Object

매개 변수

absoluteUri
Uri

ResolveUri(Uri, String)에서 반환된 URI입니다.

role
String

현재 사용되지 않습니다.

ofObjectToReturn
Type

반환할 개체의 형식입니다. 현재 구현에서는 Stream 개체만 반환합니다.

반환

Object

스트림 개체이거나, 스트림 외의 다른 형식이 지정된 경우 null입니다.

예외

ofObjectToReturnnull 또는 Stream 형식이 아닌 경우

지정된 URI가 절대 URI가 아닌 경우

absoluteUri이(가) null인 경우

런타임 오류(예: 중단된 서버 연결)가 발생한 경우

예제

다음 예제는 GetEntityResolveUri 메서드.

#using <System.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;

int main()
{
   XmlUrlResolver^ resolver = gcnew XmlUrlResolver;
   Uri^ baseUri = gcnew Uri( "http://servername/tmp/test.xsl" );
   Uri^ fulluri = resolver->ResolveUri( baseUri, "includefile.xsl" );

   // Get a stream object containing the XSL file
   Stream^ s = dynamic_cast<Stream^>(resolver->GetEntity( fulluri, nullptr, Stream::typeid ));

   // Read the stream object displaying the contents of the XSL file
   XmlTextReader^ reader = gcnew XmlTextReader( s );
   while ( reader->Read() )
   {
      Console::WriteLine( reader->ReadOuterXml() );
   }
}
using System;
using System.IO;
using System.Xml;

 public class Sample
 {

   public static void Main()
   {
       XmlUrlResolver resolver = new XmlUrlResolver();

       Uri baseUri = new Uri ("http://servername/tmp/test.xsl");

       Uri fulluri=resolver.ResolveUri(baseUri, "includefile.xsl");

       // Get a stream object containing the XSL file
       Stream s=(Stream)resolver.GetEntity(fulluri, null, typeof(Stream));

       // Read the stream object displaying the contents of the XSL file
       XmlTextReader reader = new XmlTextReader(s);
       while (reader.Read())
       {
          Console.WriteLine(reader.ReadOuterXml());
       }
   }
}
Imports System.IO
Imports System.Xml

Public Class Sample
    
  Public Shared Sub Main()

     Dim resolver As New XmlUrlResolver()
     Dim baseUri As New Uri("http://servername/tmp/test.xsl")
     Dim fulluri As Uri = resolver.ResolveUri(baseUri, "includefile.xsl")
            
     ' Get a stream object containing the XSL file
     Dim s As Stream = CType(resolver.GetEntity(fulluri, Nothing, GetType(Stream)), Stream)
            
     ' Read the stream object displaying the contents of the XSL file
     Dim reader As New XmlTextReader(s)
     While reader.Read()
        Console.WriteLine(reader.ReadOuterXml())
     End While
        
  End Sub
End Class

설명

이 메서드는 호출자가 지정된 URI를 URI가 나타내는 리소스가 포함된 개체에 매핑하려는 경우에 사용됩니다.

이 메서드의 비동기 버전은 다음을 참조하세요 GetEntityAsync.

중요

애플리케이션 메모리에 대 한 서비스 거부를 완화할 수는 GetEntity IStream을 구현 하 여 메서드 IStream 읽은 바이트 수를 제한 합니다. 이렇게 하면 악의적인 코드가 메서드에 무한 바이트 스트림을 전달하려고 시도하는 상황을 방지할 수 GetEntity 있습니다.

적용 대상

추가 정보