Share via


PackUriHelper.Create メソッド

定義

新しいパック URI を作成します。

オーバーロード

Create(Uri)

パッケージを指す新しいパック URI を作成します。

Create(Uri, Uri)

Package URI およびパッケージ内にあるパーツの URI が指定されている場合に、パック URI を作成します。

Create(Uri, Uri, String)

Package URI、パッケージ内にあるパーツの URI、および追加する "#" フラグメントが指定されている場合に、パック URI を作成します。

注釈

次の表は、 メソッドのサンプル ケースを Create 示しています。

packageUri partUri fragment 返されるパック URI
http://www.proseware.com/mypackage.pkg /page1.xaml #intro pack://http:,,www.proseware.com,mypackage.pkg/page1.xaml#intro
http://www.proseware.com/mypackage.pkg /page2.xaml null pack://http:,,www.proseware.com,mypackage.pkg/page2.xaml
http://www.proseware.com/mypackage.pkg /a/page4.xaml null pack://http:,,www.proseware.com,mypackage.pkg/a/page4.xaml
http://www.proseware.com/mypackage.pkg /%41/%61.xml null pack://http:,,www.proseware.com,mypackage.pkg/A/a.xml
http://www.proseware.com/mypackage.pkg /%25XY.xml null pack://http:,,www.proseware.com,mypackage.pkg/%25XY.xml
http://www.proseware.com/mypackage.pkg /a/page5.xaml #summary pack://http:,,www.proseware.com,mypackage.pkg/a/page5.xaml#summary
http://www.proseware.com/packages.aspx?pkg04 /page1.xaml #intro pack://http:,,www.proseware.com,packages.aspx%3fpkg04/page1.xaml#intro
http://www.proseware.com/mypackage.pkg null null pack://http:,,www.proseware.com,mypackage.pkg
ftp://ftp.proseware.com/packages/mypackage1.abc /a/mydoc.xaml null pack://ftp:,,ftp.proseware.com,packages,mypackage1.abc/a/mydoc.xaml
file:///d:/packages/mypackage2.pkg /a/bar.xaml #xref pack://file:,,,d:,packages,mypackage2.pkg/a/bar.xaml#xref

パック URI の作成は、複数ステップのプロセスです。 たとえば、パック URI を形成する手順の 1 つは、 のスラッシュ (/) 文字を packageUri コンマ (,) に置き換えます。

文字列変換とパック URI の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできる Open Packaging Conventions 仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

Create(Uri)

ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs

パッケージを指す新しいパック URI を作成します。

public:
 static Uri ^ Create(Uri ^ packageUri);
public static Uri Create (Uri packageUri);
static member Create : Uri -> Uri
Public Shared Function Create (packageUri As Uri) As Uri

パラメーター

packageUri
Uri

参照先の Package の URI。

戻り値

Uri

指定された packageUri によって参照されている Package のパック URI。

例外

packageUrinullです。

packageUri は絶対パスではありません。

次の例では、 メソッドを Create 使用して、パッケージを参照するパック URI を定義する方法を示します。

// ------------------------ GetFixedDocument --------------------------
/// <summary>
///   Returns the fixed document at a given URI within
///   the currently open XPS package.</summary>
/// <param name="fixedDocUri">
///   The URI of the fixed document to return.</param>
/// <returns>
///   The fixed document at a given URI
///   within the current XPS package.</returns>
private FixedDocument GetFixedDocument(Uri fixedDocUri)
{
    FixedDocument fixedDocument = null;

    // Create the URI for the fixed document within the package. The URI
    // is used to set the Parser context so fonts & other items can load.
    Uri tempUri = new Uri(_xpsDocumentPath, UriKind.RelativeOrAbsolute);
    ParserContext parserContext = new ParserContext();
    parserContext.BaseUri = PackUriHelper.Create(tempUri);

    // Retrieve the fixed document.
    PackagePart fixedDocPart = _xpsPackage.GetPart(fixedDocUri);
    if (fixedDocPart != null)
    {
        object fixedObject =
            XamlReader.Load(fixedDocPart.GetStream(), parserContext);
        if (fixedObject != null)
            fixedDocument = fixedObject as FixedDocument;
    }

    return fixedDocument;
}// end:GetFixedDocument()
' ------------------------ GetFixedDocument --------------------------
''' <summary>
'''   Returns the fixed document at a given URI within
'''   the currently open XPS package.</summary>
''' <param name="fixedDocUri">
'''   The URI of the fixed document to return.</param>
''' <returns>
'''   The fixed document at a given URI
'''   within the current XPS package.</returns>
Private Function GetFixedDocument(ByVal fixedDocUri As Uri) As FixedDocument
    Dim fixedDocument As FixedDocument = Nothing

    ' Create the URI for the fixed document within the package. The URI
    ' is used to set the Parser context so fonts & other items can load.
    Dim tempUri As New Uri(_xpsDocumentPath, UriKind.RelativeOrAbsolute)
    Dim parserContext As New ParserContext()
    parserContext.BaseUri = PackUriHelper.Create(tempUri)

    ' Retrieve the fixed document.
    Dim fixedDocPart As PackagePart = _xpsPackage.GetPart(fixedDocUri)
    If fixedDocPart IsNot Nothing Then
        Dim fixedObject As Object = XamlReader.Load(fixedDocPart.GetStream(), parserContext)
        If fixedObject IsNot Nothing Then
            fixedDocument = TryCast(fixedObject, FixedDocument)
        End If
    End If

    Return fixedDocument
End Function ' end:GetFixedDocument()

注釈

packageUri は、 または 空として null 指定できません。

のサンプル ケースを次の表に Create示します。

packageUri 返されるパック URI
http://www.proseware.com/mypackage.pkg pack://http:,,www.proseware.com,mypackage.pkg
ftp://ftp.proseware.com/packages/mypackage1.abc pack://ftp:,,ftp.proseware.com,packages,mypackage1.abc
file:///d:/packages/mypackage2.pkg pack://file:,,,d:,packages,mypackage2.pkg

パック URI の作成は、複数ステップのプロセスです。 たとえば、パック URI を形成する手順の 1 つは、 のスラッシュ (/) 文字を packageUri コンマ (,) に置き換えます。

文字列変換とパック URI の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできる Open Packaging Conventions 仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

こちらもご覧ください

適用対象

Create(Uri, Uri)

ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs

Package URI およびパッケージ内にあるパーツの URI が指定されている場合に、パック URI を作成します。

public:
 static Uri ^ Create(Uri ^ packageUri, Uri ^ partUri);
public static Uri Create (Uri packageUri, Uri partUri);
public static Uri Create (Uri packageUri, Uri? partUri);
static member Create : Uri * Uri -> Uri
Public Shared Function Create (packageUri As Uri, partUri As Uri) As Uri

パラメーター

packageUri
Uri

Package の URI。

partUri
Uri

パッケージ内の PackagePart の URI。

戻り値

Uri

指定された PackagePart のパック URI。

例外

packageUrinullです。

packageUri は絶対パスではありません。

- または -

partUri は有効なパーツ URI 構文ではありません。

次の例では、 メソッドを Create(Uri) 使用して、パッケージを参照するパック URI を定義する方法を示します。

// ------------------------ GetFixedDocument --------------------------
/// <summary>
///   Returns the fixed document at a given URI within
///   the currently open XPS package.</summary>
/// <param name="fixedDocUri">
///   The URI of the fixed document to return.</param>
/// <returns>
///   The fixed document at a given URI
///   within the current XPS package.</returns>
private FixedDocument GetFixedDocument(Uri fixedDocUri)
{
    FixedDocument fixedDocument = null;

    // Create the URI for the fixed document within the package. The URI
    // is used to set the Parser context so fonts & other items can load.
    Uri tempUri = new Uri(_xpsDocumentPath, UriKind.RelativeOrAbsolute);
    ParserContext parserContext = new ParserContext();
    parserContext.BaseUri = PackUriHelper.Create(tempUri);

    // Retrieve the fixed document.
    PackagePart fixedDocPart = _xpsPackage.GetPart(fixedDocUri);
    if (fixedDocPart != null)
    {
        object fixedObject =
            XamlReader.Load(fixedDocPart.GetStream(), parserContext);
        if (fixedObject != null)
            fixedDocument = fixedObject as FixedDocument;
    }

    return fixedDocument;
}// end:GetFixedDocument()
' ------------------------ GetFixedDocument --------------------------
''' <summary>
'''   Returns the fixed document at a given URI within
'''   the currently open XPS package.</summary>
''' <param name="fixedDocUri">
'''   The URI of the fixed document to return.</param>
''' <returns>
'''   The fixed document at a given URI
'''   within the current XPS package.</returns>
Private Function GetFixedDocument(ByVal fixedDocUri As Uri) As FixedDocument
    Dim fixedDocument As FixedDocument = Nothing

    ' Create the URI for the fixed document within the package. The URI
    ' is used to set the Parser context so fonts & other items can load.
    Dim tempUri As New Uri(_xpsDocumentPath, UriKind.RelativeOrAbsolute)
    Dim parserContext As New ParserContext()
    parserContext.BaseUri = PackUriHelper.Create(tempUri)

    ' Retrieve the fixed document.
    Dim fixedDocPart As PackagePart = _xpsPackage.GetPart(fixedDocUri)
    If fixedDocPart IsNot Nothing Then
        Dim fixedObject As Object = XamlReader.Load(fixedDocPart.GetStream(), parserContext)
        If fixedObject IsNot Nothing Then
            fixedDocument = TryCast(fixedObject, FixedDocument)
        End If
    End If

    Return fixedDocument
End Function ' end:GetFixedDocument()

注釈

packageUri は null または空として指定できません。

が のnull場合partUri、返されるパック URI はパッケージを指します。

次の表は、 メソッドのサンプル ケースを Create 示しています。

packageUri partUri 返されるパック URI
http://www.proseware.com/mypackage.pkg /page2.xaml pack://http:,,www.proseware.com,mypackage.pkg/page2.xaml
http://www.proseware.com/mypackage.pkg /a/page4.xaml pack://http:,,www.proseware.com,mypackage.pkg/a/page4.xaml
http://www.proseware.com/mypackage.pkg /%41/%61.xml pack://http:,,www.proseware.com,mypackage.pkg/A/a.xml
http://www.proseware.com/mypackage.pkg /%25XY.xml pack://http:,,www.proseware.com,mypackage.pkg/%25XY.xml
http://www.proseware.com/mypackage.pkg null pack://http:,,www.proseware.com,mypackage.pkg
ftp://ftp.proseware.com/packages/mypackage1.abc /a/mydoc.xaml pack://ftp:,,ftp.proseware.com,packages,mypackage1.abc/a/mydoc.xaml
file:///d:/packages/mypackage2.pkg /a/bar.xaml pack://file:,,,d:,packages,mypackage2.pkg/a/bar.xaml

パック URI の作成は、複数ステップのプロセスです。 たとえば、パック URI を形成する手順の 1 つは、 のスラッシュ (/) 文字を packageUri コンマ (,) に置き換えます。

文字列変換とパック URI の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできる Open Packaging Conventions 仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

こちらもご覧ください

適用対象

Create(Uri, Uri, String)

ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs

Package URI、パッケージ内にあるパーツの URI、および追加する "#" フラグメントが指定されている場合に、パック URI を作成します。

public:
 static Uri ^ Create(Uri ^ packageUri, Uri ^ partUri, System::String ^ fragment);
public static Uri Create (Uri packageUri, Uri partUri, string fragment);
public static Uri Create (Uri packageUri, Uri? partUri, string? fragment);
static member Create : Uri * Uri * string -> Uri
Public Shared Function Create (packageUri As Uri, partUri As Uri, fragment As String) As Uri

パラメーター

packageUri
Uri

Package の URI。

partUri
Uri

パッケージ内の PackagePart の URI。

fragment
String

パッケージ パーツ内の要素を識別する「#」参照。

戻り値

Uri

指定したパッケージ、パッケージ パーツ、およびフラグメントを識別するパック URI。

例外

packageUrinullです。

packageUri は絶対パスではありません。

- または -

partUri は有効なパーツ URI 構文ではありません。

- または -

fragment は空であるか、または「#」で始まっています。

次の例では、 メソッドを Create(Uri) 使用して、パッケージを参照するパック URI を定義する方法を示します。

// ------------------------ GetFixedDocument --------------------------
/// <summary>
///   Returns the fixed document at a given URI within
///   the currently open XPS package.</summary>
/// <param name="fixedDocUri">
///   The URI of the fixed document to return.</param>
/// <returns>
///   The fixed document at a given URI
///   within the current XPS package.</returns>
private FixedDocument GetFixedDocument(Uri fixedDocUri)
{
    FixedDocument fixedDocument = null;

    // Create the URI for the fixed document within the package. The URI
    // is used to set the Parser context so fonts & other items can load.
    Uri tempUri = new Uri(_xpsDocumentPath, UriKind.RelativeOrAbsolute);
    ParserContext parserContext = new ParserContext();
    parserContext.BaseUri = PackUriHelper.Create(tempUri);

    // Retrieve the fixed document.
    PackagePart fixedDocPart = _xpsPackage.GetPart(fixedDocUri);
    if (fixedDocPart != null)
    {
        object fixedObject =
            XamlReader.Load(fixedDocPart.GetStream(), parserContext);
        if (fixedObject != null)
            fixedDocument = fixedObject as FixedDocument;
    }

    return fixedDocument;
}// end:GetFixedDocument()
' ------------------------ GetFixedDocument --------------------------
''' <summary>
'''   Returns the fixed document at a given URI within
'''   the currently open XPS package.</summary>
''' <param name="fixedDocUri">
'''   The URI of the fixed document to return.</param>
''' <returns>
'''   The fixed document at a given URI
'''   within the current XPS package.</returns>
Private Function GetFixedDocument(ByVal fixedDocUri As Uri) As FixedDocument
    Dim fixedDocument As FixedDocument = Nothing

    ' Create the URI for the fixed document within the package. The URI
    ' is used to set the Parser context so fonts & other items can load.
    Dim tempUri As New Uri(_xpsDocumentPath, UriKind.RelativeOrAbsolute)
    Dim parserContext As New ParserContext()
    parserContext.BaseUri = PackUriHelper.Create(tempUri)

    ' Retrieve the fixed document.
    Dim fixedDocPart As PackagePart = _xpsPackage.GetPart(fixedDocUri)
    If fixedDocPart IsNot Nothing Then
        Dim fixedObject As Object = XamlReader.Load(fixedDocPart.GetStream(), parserContext)
        If fixedObject IsNot Nothing Then
            fixedDocument = TryCast(fixedObject, FixedDocument)
        End If
    End If

    Return fixedDocument
End Function ' end:GetFixedDocument()

注釈

packageUri は、 または 空として null 指定できません。

が のnull場合partUri、返されるパック URI はパッケージを指します。

fragment は空の文字列にすることはできませんが、 として null指定できます。 として null指定しない場合、文字列は fragment '#' 文字で始まる必要があります。 参照の構文の fragment 詳細については、 RFC 3986 のセクション 3.5「Fragment」を参照してください。

次の表は、 メソッドのサンプル ケースを Create 示しています。

packageUri partUri fragment 返されるパック URI
http://www.proseware.com/mypackage.pkg /page1.xaml #intro pack://http:,,www.proseware.com,mypackage.pkg/page1.xaml#intro
http://www.proseware.com/mypackage.pkg /page2.xaml null pack://http:,,www.proseware.com,mypackage.pkg/page2.xaml
http://www.proseware.com/mypackage.pkg /a/page4.xaml null pack://http:,,www.proseware.com,mypackage.pkg/a/page4.xaml
http://www.proseware.com/mypackage.pkg /%41/%61.xml null pack://http:,,www.proseware.com,mypackage.pkg/A/a.xml
http://www.proseware.com/mypackage.pkg /%25XY.xml null pack://http:,,www.proseware.com,mypackage.pkg/%25XY.xml
http://www.proseware.com/mypackage.pkg /a/page5.xaml #summary pack://http:,,www.proseware.com,mypackage.pkg/a/page5.xaml#summary
http://www.proseware.com/packages.aspx?pkg04 /page1.xaml #intro pack://http:,,www.proseware.com,packages.aspx%3fpkg04/page1.xaml#intro
http://www.proseware.com/mypackage.pkg null null pack://http:,,www.proseware.com,mypackage.pkg
ftp://ftp.proseware.com/packages/mypackage1.abc /a/mydoc.xaml null pack://ftp:,,ftp.proseware.com,packages,mypackage1.abc/a/mydoc.xaml
file:///d:/packages/mypackage2.pkg /a/bar.xaml #xref pack://file:,,,d:,packages,mypackage2.pkg/a/bar.xaml#xref

パック URI の作成は、複数ステップのプロセスです。 たとえば、パック URI を形成する手順の 1 つは、 のスラッシュ (/) 文字を packageUri コンマ (,) に置き換えます。

文字列変換とパック URI の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできる Open Packaging Conventions 仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

こちらもご覧ください

適用対象