UnsignedPublishLicense Construtores

Definição

Inicializa uma nova instância da UnsignedPublishLicense classe.

Sobrecargas

Name Description
UnsignedPublishLicense()

Inicializa uma nova instância da UnsignedPublishLicense classe.

UnsignedPublishLicense(String)

Inicializa uma nova instância da UnsignedPublishLicense classe a partir de um modelo de publicação XrML especificado.

UnsignedPublishLicense()

Inicializa uma nova instância da UnsignedPublishLicense classe.

public:
 UnsignedPublishLicense();
public UnsignedPublishLicense();
Public Sub New ()

Observações

UnsignedPublishLicense cria uma licença de publicação vazia e sem assinatura.

Aplica-se a

UnsignedPublishLicense(String)

Inicializa uma nova instância da UnsignedPublishLicense classe a partir de um modelo de publicação XrML especificado.

public:
 UnsignedPublishLicense(System::String ^ publishLicenseTemplate);
public UnsignedPublishLicense(string publishLicenseTemplate);
new System.Security.RightsManagement.UnsignedPublishLicense : string -> System.Security.RightsManagement.UnsignedPublishLicense
Public Sub New (publishLicenseTemplate As String)

Parâmetros

publishLicenseTemplate
String

O modelo de licença de publicação Extensible Rights Markup Language (XrML) para usar na criação desta licença.

Exemplos

O exemplo seguinte mostra como usar este construtor.

WriteStatus("   Reading '" + xrmlFilename + "' permissions.");
try
{
    StreamReader sr = File.OpenText(xrmlFile);
    xrmlString = sr.ReadToEnd();
}
catch (Exception ex)
{
    MessageBox.Show("ERROR: '" + xrmlFilename + "' open failed.\n" +
        "Exception: " + ex.Message, "XrML File Error",
        MessageBoxButton.OK, MessageBoxImage.Error);
    return false;
}

WriteStatus("   Building UnsignedPublishLicense");
WriteStatus("       from '" + xrmlFilename + "'.");
UnsignedPublishLicense unsignedLicense =
    new UnsignedPublishLicense(xrmlString);
ContentUser author = unsignedLicense.Owner;
WriteStatus("   Reading '" & xrmlFilename & "' permissions.")
Try
    Dim sr As StreamReader = File.OpenText(xrmlFile)
    xrmlString = sr.ReadToEnd()
Catch ex As Exception
    MessageBox.Show("ERROR: '" & xrmlFilename &"' open failed." & vbLf & "Exception: " & ex.Message, "XrML File Error", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

WriteStatus("   Building UnsignedPublishLicense")
WriteStatus("       from '" & xrmlFilename & "'.")
Dim unsignedLicense As New UnsignedPublishLicense(xrmlString)
Dim author As ContentUser = unsignedLicense.Owner

Observações

O publishLicenseTemplate XrML <RANGETIME> ou <INTERVALTIME> elementos são ignorados quando o UnsignedPublishLicense é criado pelo UnsignedPublishLicenseconstrutor (String). Para especificar estes valores para a licença de publicação, as ContentGrant propriedades de ValidFrom e ValidUntil devem ser explicitamente definidas. O exemplo seguinte mostra como definir explicitamente as ValidFrom propriedades e ValidUntil .

// The XRML template <RANGETIME> and <INTERVALTIME> elements are
// ignored by the UnsignedPublishLicense(xrmlString) constructor.
// To specify these values for the license, the ContentGrant
// ValidFrom and ValidUntil properties must be explicitly set.
// The following code sample demonstrates how to set the
// ContentGrant properties for ValidFrom and ValidUntil.

// Create a copy of the original XRML template ContentGrants
// set by the UnsignedPublishLicense(xrmlString) constructor.
ICollection<ContentGrant> tmpGrants = new List<ContentGrant>();
foreach (ContentGrant grant in unsignedLicense.Grants)
    tmpGrants.Add(grant);

// Erase all original UnsignedPublishLicense ContentGrants.
unsignedLicense.Grants.Clear();

// Add each original grant back to the UnsignedPublishLicense
// with appropriate ValidFrom and ValidUntil date/time values.
foreach (ContentGrant grant in tmpGrants)
{
    unsignedLicense.Grants.Add(new ContentGrant(
        grant.User, grant.Right,
        DateTime.MinValue,    // set ValidFrom as appropriate
        DateTime.MaxValue));  // set ValidUntil as appropriate
}
' The XRML template <RANGETIME> and <INTERVALTIME> elements are
' ignored by the UnsignedPublishLicense(xrmlString) constructor.
' To specify these values for the license, the ContentGrant
' ValidFrom and ValidUntil properties must be explicitly set.
' The following code sample demonstrates how to set the
' ContentGrant properties for ValidFrom and ValidUntil.

' Create a copy of the original XRML template ContentGrants
' set by the UnsignedPublishLicense(xrmlString) constructor.
Dim tmpGrants As ICollection(Of ContentGrant) = New List(Of ContentGrant)()
For Each grant As ContentGrant In unsignedLicense.Grants
    tmpGrants.Add(grant)
Next grant

' Erase all original UnsignedPublishLicense ContentGrants.
unsignedLicense.Grants.Clear()

' Add each original grant back to the UnsignedPublishLicense
' with appropriate ValidFrom and ValidUntil date/time values.
For Each grant As ContentGrant In tmpGrants
    unsignedLicense.Grants.Add(New ContentGrant(grant.User, grant.Right, Date.MinValue, Date.MaxValue)) ' set ValidUntil as appropriate -  set ValidFrom as appropriate
Next grant

Aplica-se a