Language

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 の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできるオープン パッケージ規則仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

Create(Uri)

ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
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

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

例外

packageUri は nullです。

packageUri は絶対 URI ではありません。

例

次の例では、 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 の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできるオープン パッケージ規則仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

こちらもご覧ください

適用対象

Create(Uri, Uri)

ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
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。

例外

packageUri は nullです。

packageUri は絶対 URI ではありません。

-又は-

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 または空として指定できません。

partUriがnull場合、返されるパック 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 の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできるオープン パッケージ規則仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

こちらもご覧ください

適用対象

Create(Uri, Uri, String)

ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
PackUriHelper.PackUriScheme.cs
ソース:
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。

例外

packageUri は nullです。

packageUri は絶対 URI ではありません。

-又は-

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 または空として指定できません。

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

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

次の表に、 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 の形成方法の詳細については、「 仕様とライセンスダウンロード」でダウンロードできるオープン パッケージ規則仕様の付録 A.4 「文字列変換の例」および付録 B.3「パック URI の作成」を参照してください。

こちらもご覧ください

適用対象