Sdílet prostřednictvím


PackUriHelper.Create Metoda

Definice

Vytvoří nový identifikátor URI balíčku.

Přetížení

Create(Uri)

Vytvoří nový identifikátor URI balíčku, který odkazuje na balíček.

Create(Uri, Uri)

Vytvoří identifikátor URI balíčku s daným identifikátorem Package URI a identifikátorem URI části balíčku.

Create(Uri, Uri, String)

Vytvoří identifikátor URI balíčku s daným identifikátorem Package URI, identifikátorem URI části balíčku a fragmentem #, který se má připojit.

Poznámky

Následující tabulka ukazuje ukázkové případy pro metodu Create .

packageUri partUri fragment Vrácený identifikátor URI balíčku
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

Vytvoření identifikátoru URI balíčku je vícekrokový proces. Jedním z kroků při vytváření identifikátoru URI balíčku je například nahrazení znaků lomítka (/) packageUri čárkami (,).

Další informace o převodu řetězců a způsobu vytváření identifikátorů URI balíčku najdete v příloze A.4 "Příklady převodu řetězců" a v příloze B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, která je k dispozici ke stažení na stránce Specifikace a stažení licencí.

Create(Uri)

Zdroj:
PackUriHelper.PackUriScheme.cs
Zdroj:
PackUriHelper.PackUriScheme.cs
Zdroj:
PackUriHelper.PackUriScheme.cs

Vytvoří nový identifikátor URI balíčku, který odkazuje na balíček.

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

Parametry

packageUri
Uri

Identifikátor URI odkazovaného Packagesouboru

Návraty

Uri

Identifikátor URI balíčku pro odkazovaný Package daným packageUriidentifikátorem .

Výjimky

packageUri je null.

packageUri není absolutní identifikátor URI.

Příklady

Následující příklad ukazuje, jak pomocí Create metody definovat identifikátor URI balíčku, který odkazuje na balíček.

// ------------------------ 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()

Poznámky

packageUri nesmí být zadána jako null nebo prázdná.

Následující tabulka ukazuje ukázkové případy pro Create.

packageUri Vrácený identifikátor URI balíčku
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

Vytvoření identifikátoru URI balíčku je proces s více kroky. Jedním z kroků při vytváření identifikátoru URI balíčku je například nahrazení lomítka (/) packageUri znaku čárkami (,).

Další informace o převodu řetězců a o tom, jak se vytvářejí identifikátory URI balíčku, najdete v příloze A.4 "Příklady převodu řetězců" a v příloze B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, která je k dispozici ke stažení na stránce Specifikace a stažení licencí.

Viz také

Platí pro

Create(Uri, Uri)

Zdroj:
PackUriHelper.PackUriScheme.cs
Zdroj:
PackUriHelper.PackUriScheme.cs
Zdroj:
PackUriHelper.PackUriScheme.cs

Vytvoří identifikátor URI balíčku s daným identifikátorem Package URI a identifikátorem URI části balíčku.

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

Parametry

packageUri
Uri

Identifikátor URI souboru Package.

partUri
Uri

Identifikátor URI v PackagePart balíčku.

Návraty

Uri

Identifikátor URI balíčku daného PackagePartsouboru .

Výjimky

packageUri je null.

packageUri není absolutní identifikátor URI.

-nebo-

partUri není platná syntaxe identifikátoru URI části.

Příklady

Následující příklad ukazuje, jak pomocí Create(Uri) metody definovat identifikátor URI balíčku, který odkazuje na balíček.

// ------------------------ 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()

Poznámky

packageUri nesmí být zadána jako null nebo prázdná.

Pokud partUri je null, vrácený identifikátor URI balíčku odkazuje na balíček.

Následující tabulka ukazuje ukázkové případy pro metodu Create .

packageUri partUri Vrácený identifikátor URI balíčku
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

Vytvoření identifikátoru URI balíčku je proces s více kroky. Jedním z kroků při vytváření identifikátoru URI balíčku je například nahrazení lomítka (/) packageUri znaku čárkami (,).

Další informace o převodu řetězců a o tom, jak se vytvářejí identifikátory URI balíčku, najdete v příloze A.4 "Příklady převodu řetězců" a v příloze B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, která je k dispozici ke stažení na stránce Specifikace a stažení licencí.

Viz také

Platí pro

Create(Uri, Uri, String)

Zdroj:
PackUriHelper.PackUriScheme.cs
Zdroj:
PackUriHelper.PackUriScheme.cs
Zdroj:
PackUriHelper.PackUriScheme.cs

Vytvoří identifikátor URI balíčku s identifikátorem Package URI, identifikátorem URI části balíčku a fragmentem #, který se má připojit.

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

Parametry

packageUri
Uri

Identifikátor URI souboru Package.

partUri
Uri

Identifikátor URI v PackagePart balíčku.

fragment
String

Odkaz #, který identifikuje prvek v části balíčku.

Návraty

Uri

Identifikátor URI balíčku, který identifikuje zadaný balíček, část balíčku a fragment.

Výjimky

packageUri je null.

packageUri není absolutní identifikátor URI.

-nebo-

partUri není platná syntaxe identifikátoru URI části.

-nebo-

fragment je prázdný nebo začíná na "#".

Příklady

Následující příklad ukazuje, jak pomocí Create(Uri) metody definovat identifikátor URI balíčku, který odkazuje na balíček.

// ------------------------ 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()

Poznámky

packageUri nesmí být zadána jako null nebo prázdná.

Pokud partUri je null, vrácený identifikátor URI balíčku odkazuje na balíček.

fragment nemůže být prázdný řetězec, ale lze ho zadat jako null. Pokud není řetězec zadaný jako null, fragment musí řetězec začínat znakem #. Další informace o syntaxi fragment odkazů najdete v oddílu 3.5 "Fragment" dokumentu RFC 3986.

Následující tabulka ukazuje ukázkové případy pro metodu Create .

packageUri partUri fragment Vrácený identifikátor URI balíčku
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

Vytvoření identifikátoru URI balíčku je vícekrokový proces. Jedním z kroků při vytváření identifikátoru URI balíčku je například nahrazení znaků lomítka (/) packageUri čárkami (,).

Další informace o převodu řetězců a způsobu vytváření identifikátorů URI balíčku najdete v příloze A.4 "Příklady převodu řetězců" a v příloze B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, která je k dispozici ke stažení na stránce Specifikace a stažení licencí.

Viz také

Platí pro