PackUriHelper.Create Método

Definição

Cria um novo URI do pacote.

Sobrecargas

Name Description
Create(Uri)

Cria um novo URI de pacote que aponta para um pacote.

Create(Uri, Uri)

Cria um URI de pacote dado um Package URI e o URI de uma peça no pacote.

Create(Uri, Uri, String)

Cria um URI de pacote dado um Package URI, o URI de uma peça no pacote e um fragmento "#" para adicionar.

Observações

A tabela seguinte ilustra casos exemplos para o Create método.

packageUri partUri fragment URI de mochila devolvido
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

Compor um URI de pacote é um processo em várias etapas. Por exemplo, um passo na formação de um URI de pacote é substituir os caracteres de barra frontal (/) do packageUri por vírgulas (,).

Para mais informações sobre conversão de cadeias e como os URI de pacote são formados, consulte o Apêndice A.4 "Exemplos de Conversão de Cadeias" e o Apêndice B.3 "Compor um URI de pacote" na especificação Open Packaging Conventions disponível para download em Especificações e Downloads de Licença.

Create(Uri)

Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs

Cria um novo URI de pacote que aponta para um pacote.

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

Parâmetros

packageUri
Uri

O URI dos referidos Package.

Devoluções

Uri

O URI do pacote para o Package referenciado pelo dado packageUri.

Exceções

packageUri é null.

packageUri não é um URI absoluto.

Exemplos

O exemplo seguinte mostra como usar o Create método para definir um URI de pacote que faz referência a um pacote.

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

Observações

packageUri pode não ser especificado como null ou vazio.

A tabela seguinte ilustra casos exemplos para Create.

packageUri URI de mochila devolvido
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

Compor um URI de pacote é um processo em várias etapas. Por exemplo, um passo na formação de um URI de pacote é substituir os caracteres de barra frontal (/) do packageUri por vírgulas (,).

Para mais informações sobre conversão de cadeias e como os URI de pacote são formados, consulte o Apêndice A.4 "Exemplos de Conversão de Cadeias" e o Apêndice B.3 "Compor um URI de pacote" na especificação Open Packaging Conventions disponível para download em Especificações e Downloads de Licença.

Ver também

Aplica-se a

Create(Uri, Uri)

Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs

Cria um URI de pacote dado um Package URI e o URI de uma peça no pacote.

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

Parâmetros

packageUri
Uri

O URI do Packagearquivo .

partUri
Uri

O URI do PackagePart no pacote.

Devoluções

Uri

O URI do pacote do dado PackagePart.

Exceções

packageUri é null.

packageUri não é um URI absoluto.

-ou-

partUri não é uma sintaxe válida de URI de partes.

Exemplos

O exemplo seguinte mostra como usar o Create(Uri) método para definir um URI de pacote que faz referência a um pacote.

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

Observações

packageUri não pode ser especificado como nulo ou vazio.

Se partUri for null, o URI do pacote devolvido aponta para o pacote.

A tabela seguinte ilustra casos exemplos para o Create método.

packageUri partUri URI de mochila devolvido
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

Compor um URI de pacote é um processo em várias etapas. Por exemplo, um passo na formação de um URI de pacote é substituir os caracteres de barra frontal (/) do packageUri por vírgulas (,).

Para mais informações sobre conversão de cadeias e como os URI de pacote são formados, consulte o Apêndice A.4 "Exemplos de Conversão de Cadeias" e o Apêndice B.3 "Compor um URI de pacote" na especificação Open Packaging Conventions disponível para download em Especificações e Downloads de Licença.

Ver também

Aplica-se a

Create(Uri, Uri, String)

Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs
Origem:
PackUriHelper.PackUriScheme.cs

Cria um URI de pacote dado um Package URI, o URI de uma peça no pacote e um fragmento "#" para adicionar.

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

Parâmetros

packageUri
Uri

O URI do Packagearquivo .

partUri
Uri

O URI do PackagePart no pacote.

fragment
String

Uma referência "#" que identifica um elemento dentro da parte do pacote.

Devoluções

Uri

O URI do pacote que identifica o pacote especificado, a parte do pacote e o fragmento.

Exceções

packageUri é null.

packageUri não é um URI absoluto.

-ou-

partUri não é uma sintaxe válida de URI de partes.

-ou-

fragment é vazio ou começa por "#".

Exemplos

O exemplo seguinte mostra como usar o Create(Uri) método para definir um URI de pacote que faz referência a um pacote.

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

Observações

packageUri pode não ser especificado como null ou vazio.

Se partUri for null, o URI do pacote devolvido aponta para o pacote.

fragment não pode ser uma cadeia vazia, mas pode ser especificada como null. Quando não especificado como null, a fragment cadeia deve começar com um carácter '#'. Para mais informações sobre a sintaxe das fragment referências, consulte a Secção 3.5 "Fragmento" do RFC 3986.

A tabela seguinte ilustra casos exemplos para o Create método.

packageUri partUri fragment URI de mochila devolvido
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

Compor um URI de pacote é um processo em várias etapas. Por exemplo, um passo na formação de um URI de pacote é substituir os caracteres de barra frontal (/) do packageUri por vírgulas (,).

Para mais informações sobre conversão de cadeias e como os URI de pacote são formados, consulte o Apêndice A.4 "Exemplos de Conversão de Cadeias" e o Apêndice B.3 "Compor um URI de pacote" na especificação Open Packaging Conventions disponível para download em Especificações e Downloads de Licença.

Ver também

Aplica-se a