URI を実際のリソースを含むオブジェクトに割り当てます。
Overrides Public Function GetEntity( _
ByVal absoluteUri As Uri, _ ByVal role As String, _ ByVal ofObjectToReturn As Type _) As Object
[C#]
public override object GetEntity(UriabsoluteUri,stringrole,TypeofObjectToReturn);
[C++]
public: Object* GetEntity(Uri* absoluteUri,String* role,Type* ofObjectToReturn);
[JScript]
public override function GetEntity(
absoluteUri : Uri,role : String,ofObjectToReturn : Type) : Object;
パラメータ
- absoluteUri
ResolveUri から返された URI。 - role
現在の実装は、URI を解決するときにこのパラメータを使用しません。このパラメータは、将来の拡張のために提供されています。たとえば、このパラメータを xlink:role に割り当て、別の場合に実装固有の引数として使用できます。 - ofObjectToReturn
返すオブジェクトの型。現在の実装だけが、 System.IO.Stream オブジェクトを返します。
戻り値
System.IO.Stream オブジェクト。ストリーム以外の型が指定された場合は null 参照 (Visual Basic では Nothing) 。
例外
例外の種類 | 条件 |
---|---|
XmlException | ofObjectToReturn が null 参照 (Visual Basic では Nothing) でも Stream 型でもありません。 |
UriFormatException | 指定した URI が絶対 URI ではありません。 |
NullReferenceException | absoluteUri が null 参照 (Visual Basic では Nothing) です。 |
Exception | ランタイム エラー (サーバー接続の中断など) があります。 |
解説
呼び出し元が指定した URI が表す実際のリソースを含むオブジェクトにその URI を割り当てるとき、このメソッドが使用されます。
使用例
[Visual Basic, C#, C++] GetEntity メソッドと ResolveUri メソッドの例を次に示します。
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim resolver As New XmlUrlResolver()
Dim baseUri As New Uri("https://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 'New
End Class 'Sample
[C#]
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
XmlUrlResolver resolver = new XmlUrlResolver();
Uri baseUri = new Uri ("https://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());
}
}
}
[C++]
#using <mscorlib.dll>
#using <System.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
XmlUrlResolver* resolver = new XmlUrlResolver();
Uri* baseUri = new Uri (S"https://servername/tmp/test.xsl");
Uri* fulluri=resolver->ResolveUri(baseUri, S"includefile.xsl");
// Get a stream object containing the XSL file
Stream* s = dynamic_cast<Stream*>(resolver->GetEntity(fulluri, 0, __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());
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard
参照
XmlUrlResolver クラス | XmlUrlResolver メンバ | System.Xml 名前空間 | Uri