PackUriHelper.Create Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Vytvoří nový identifikátor URI balíčku.
Přetížení
| Name | Description |
|---|---|
| Create(Uri) |
Vytvoří nový identifikátor URI balíčku, který odkazuje na balíček. |
| Create(Uri, Uri) |
Vytvoří identifikátor URI balíčku s identifikátorem Package URI a identifikátor URI části balíčku. |
| Create(Uri, Uri, String) |
Vytvoří identifikátor URI balíčku s identifikátorem Package URI, identifikátor URI části balíčku a fragment #, 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 | nula | pack://http:,,www.proseware.com,mypackage.pkg/page2.xaml |
http://www.proseware.com/mypackage.pkg |
/a/page4.xaml | nula | pack://http:,,www.proseware.com,mypackage.pkg/a/page4.xaml |
http://www.proseware.com/mypackage.pkg |
/%41/%61.xml | nula | pack://http:,,www.proseware.com,mypackage.pkg/A/a.xml |
http://www.proseware.com/mypackage.pkg |
/%25XY.xml | nula | 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 |
nula | nula | pack://http:,,www.proseware.com,mypackage.pkg |
ftp://ftp.proseware.com/packages/mypackage1.abc |
/a/mydoc.xaml | nula | 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 proces s více kroky. Jedním krokem při vytvoření identifikátoru URI balíčku je například nahrazení znaků packageUri lomítka (/) čárkami (,).
Další informace o převodu řetězců a způsobu vytvoření identifikátorů URI balíčků naleznete v dodatku A.4 "Příklady převodu řetězců" a dodatek B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, které jsou k dispozici ke stažení v části Specifikace a stažení licencí.
Create(Uri)
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
Návraty
Identifikátor URI balíčku pro Package odkazované daným packageUrikódem .
Výjimky
packageUri je null.
packageUri není absolutní identifikátor URI.
Příklady
Následující příklad ukazuje, jak použít metodu Create k definování identifikátoru 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 nelze zadat 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 krokem při vytvoření identifikátoru URI balíčku je například nahrazení znaků packageUri lomítka (/) čárkami (,).
Další informace o převodu řetězců a způsobu vytvoření identifikátorů URI balíčků naleznete v dodatku A.4 "Příklady převodu řetězců" a dodatek B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, které jsou k dispozici ke stažení v části Specifikace a stažení licencí.
Viz také
Platí pro
Create(Uri, Uri)
Vytvoří identifikátor URI balíčku s identifikátorem Package URI a identifikátor 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
- partUri
- Uri
Identifikátor URI balíčku PackagePart .
Návraty
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 použít metodu Create(Uri) k definování identifikátoru 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 |
nula | 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 krokem při vytvoření identifikátoru URI balíčku je například nahrazení znaků packageUri lomítka (/) čárkami (,).
Další informace o převodu řetězců a způsobu vytvoření identifikátorů URI balíčků naleznete v dodatku A.4 "Příklady převodu řetězců" a dodatek B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, které jsou k dispozici ke stažení v části Specifikace a stažení licencí.
Viz také
Platí pro
Create(Uri, Uri, String)
Vytvoří identifikátor URI balíčku s identifikátorem Package URI, identifikátor URI části balíčku a fragment #, 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
- partUri
- Uri
Identifikátor URI balíčku PackagePart .
- fragment
- String
Odkaz "#" identifikující prvek v rámci části balíčku.
Návraty
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 použít metodu Create(Uri) k definování identifikátoru 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 nelze zadat 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 jej zadat jako null. Pokud není zadaný jako null, fragment řetězec musí začínat znakem #. Další informace o syntaxi fragment odkazů naleznete v části 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 | nula | pack://http:,,www.proseware.com,mypackage.pkg/page2.xaml |
http://www.proseware.com/mypackage.pkg |
/a/page4.xaml | nula | pack://http:,,www.proseware.com,mypackage.pkg/a/page4.xaml |
http://www.proseware.com/mypackage.pkg |
/%41/%61.xml | nula | pack://http:,,www.proseware.com,mypackage.pkg/A/a.xml |
http://www.proseware.com/mypackage.pkg |
/%25XY.xml | nula | 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 |
nula | nula | pack://http:,,www.proseware.com,mypackage.pkg |
ftp://ftp.proseware.com/packages/mypackage1.abc |
/a/mydoc.xaml | nula | 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 proces s více kroky. Jedním krokem při vytvoření identifikátoru URI balíčku je například nahrazení znaků packageUri lomítka (/) čárkami (,).
Další informace o převodu řetězců a způsobu vytvoření identifikátorů URI balíčků naleznete v dodatku A.4 "Příklady převodu řetězců" a dodatek B.3 "Vytvoření identifikátoru URI balíčku" ve specifikaci Open Packaging Conventions, které jsou k dispozici ke stažení v části Specifikace a stažení licencí.