PackUriHelper.Create Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Crée un URI de pack.
Surcharges
| Nom | Description |
|---|---|
| Create(Uri) |
Crée un URI de pack qui pointe vers un package. |
| Create(Uri, Uri) |
Crée un URI de pack en fonction d’un Package URI et de l’URI d’un composant dans le package. |
| Create(Uri, Uri, String) |
Crée un URI de pack en fonction d’un Package URI, de l’URI d’un composant dans le package et d’un fragment « # » à ajouter. |
Remarques
Le tableau suivant illustre des exemples de cas pour la Create méthode.
packageUri |
partUri |
fragment |
URI de pack retourné |
|---|---|---|---|
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 | zéro | pack://http :,www.proseware.com,mypackage.pkg/page2.xaml |
http://www.proseware.com/mypackage.pkg |
/a/page4.xaml | zéro | pack://http :,www.proseware.com,mypackage.pkg/a/page4.xaml |
http://www.proseware.com/mypackage.pkg |
/%41/ %61.xml | zéro | pack://http :,www.proseware.com,mypackage.pkg/A/a.xml |
http://www.proseware.com/mypackage.pkg |
/ %25XY.xml | zéro | 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 |
zéro | zéro | pack://http :,www.proseware.com,mypackage.pkg |
ftp://ftp.proseware.com/packages/mypackage1.abc |
/a/mydoc.xaml | zéro | 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 |
La composition d’un URI de pack est un processus en plusieurs étapes. Par exemple, une étape dans la formation d’un URI de pack consiste à remplacer les caractères de barre oblique (/) des packageUri virgules (,).
Pour plus d’informations sur la conversion de chaînes et la façon dont les URI de pack sont formés, consultez l’annexe A.4 « Exemples de conversion de chaînes » et l’annexe B.3 « Composition d’un URI pack » dans la spécification Open Packaging Conventions disponible pour le téléchargement sur les spécifications et les téléchargements de licence.
Create(Uri)
Crée un URI de pack qui pointe vers un package.
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
Paramètres
Retours
URI de pack pour l’objet Package référencé par le fichier donné packageUri.
Exceptions
packageUri a la valeur null.
packageUri n’est pas un URI absolu.
Exemples
L’exemple suivant montre comment utiliser la Create méthode pour définir un URI de pack qui fait référence à un package.
// ------------------------ 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()
Remarques
packageUri peut ne pas être spécifié comme null ou vide.
Le tableau suivant illustre des exemples de cas pour Create.
packageUri |
URI de pack retourné |
|---|---|
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 |
La composition d’un URI de pack est un processus en plusieurs étapes. Par exemple, une étape dans la formation d’un URI de pack consiste à remplacer les caractères de barre oblique (/) des packageUri virgules (,).
Pour plus d’informations sur la conversion de chaînes et la façon dont les URI de pack sont formés, consultez l’annexe A.4 « Exemples de conversion de chaînes » et l’annexe B.3 « Composition d’un URI pack » dans la spécification Open Packaging Conventions disponible pour le téléchargement sur les spécifications et les téléchargements de licence.
Voir aussi
S’applique à
Create(Uri, Uri)
Crée un URI de pack en fonction d’un Package URI et de l’URI d’un composant dans le package.
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
Paramètres
- partUri
- Uri
URI du PackagePart package.
Retours
URI de pack de l’élément donné PackagePart.
Exceptions
packageUri a la valeur null.
packageUri n’est pas un URI absolu.
-ou-
partUri n’est pas une syntaxe d’URI de composant valide.
Exemples
L’exemple suivant montre comment utiliser la Create(Uri) méthode pour définir un URI de pack qui fait référence à un package.
// ------------------------ 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()
Remarques
packageUri peut ne pas être spécifié comme null ou vide.
Si partUri c’est nullle cas, l’URI du pack retourné pointe vers le package.
Le tableau suivant illustre des exemples de cas pour la Create méthode.
packageUri |
partUri |
URI de pack retourné |
|---|---|---|
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 |
zéro | 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 |
La composition d’un URI de pack est un processus en plusieurs étapes. Par exemple, une étape dans la formation d’un URI de pack consiste à remplacer les caractères de barre oblique (/) des packageUri virgules (,).
Pour plus d’informations sur la conversion de chaînes et la façon dont les URI de pack sont formés, consultez l’annexe A.4 « Exemples de conversion de chaînes » et l’annexe B.3 « Composition d’un URI pack » dans la spécification Open Packaging Conventions disponible pour le téléchargement sur les spécifications et les téléchargements de licence.
Voir aussi
S’applique à
Create(Uri, Uri, String)
Crée un URI de pack en fonction d’un Package URI, de l’URI d’un composant dans le package et d’un fragment « # » à ajouter.
public:
static Uri ^ Create(Uri ^ packageUri, Uri ^ partUri, System::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
Paramètres
- partUri
- Uri
URI du PackagePart package.
- fragment
- String
Référence « # » identifiant un élément dans la partie package.
Retours
URI de pack qui identifie le package, la partie package et le fragment spécifiés.
Exceptions
packageUri a la valeur null.
packageUri n’est pas un URI absolu.
-ou-
partUri n’est pas une syntaxe d’URI de composant valide.
-ou-
fragment est vide ou commence par « # ».
Exemples
L’exemple suivant montre comment utiliser la Create(Uri) méthode pour définir un URI de pack qui fait référence à un package.
// ------------------------ 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()
Remarques
packageUri peut ne pas être spécifié comme null ou vide.
Si partUri c’est nullle cas, l’URI du pack retourné pointe vers le package.
fragment ne peut pas être une chaîne vide, mais peut être spécifiée en tant que null. Lorsqu’elle n’est pas spécifiée null, la fragment chaîne doit commencer par un caractère « # ». Pour plus d’informations sur la syntaxe des fragment références, consultez la section 3.5 « Fragment » de RFC 3986.
Le tableau suivant illustre des exemples de cas pour la Create méthode.
packageUri |
partUri |
fragment |
URI de pack retourné |
|---|---|---|---|
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 | zéro | pack://http :,www.proseware.com,mypackage.pkg/page2.xaml |
http://www.proseware.com/mypackage.pkg |
/a/page4.xaml | zéro | pack://http :,www.proseware.com,mypackage.pkg/a/page4.xaml |
http://www.proseware.com/mypackage.pkg |
/%41/ %61.xml | zéro | pack://http :,www.proseware.com,mypackage.pkg/A/a.xml |
http://www.proseware.com/mypackage.pkg |
/ %25XY.xml | zéro | 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 |
zéro | zéro | pack://http :,www.proseware.com,mypackage.pkg |
ftp://ftp.proseware.com/packages/mypackage1.abc |
/a/mydoc.xaml | zéro | 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 |
La composition d’un URI de pack est un processus en plusieurs étapes. Par exemple, une étape dans la formation d’un URI de pack consiste à remplacer les caractères de barre oblique (/) des packageUri virgules (,).
Pour plus d’informations sur la conversion de chaînes et la façon dont les URI de pack sont formés, consultez l’annexe A.4 « Exemples de conversion de chaînes » et l’annexe B.3 « Composition d’un URI pack » dans la spécification Open Packaging Conventions disponible pour le téléchargement sur les spécifications et les téléchargements de licence.