UnsignedPublishLicense コンストラクター

定義

UnsignedPublishLicense クラスの新しいインスタンスを初期化します。

オーバーロード

UnsignedPublishLicense()

UnsignedPublishLicense クラスの新しいインスタンスを初期化します。

UnsignedPublishLicense(String)

指定した XrML 発行ライセンス テンプレートから、 クラスの UnsignedPublishLicense 新しいインスタンスを初期化します。

UnsignedPublishLicense()

UnsignedPublishLicense クラスの新しいインスタンスを初期化します。

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

注釈

UnsignedPublishLicense は、空の署名されていない発行ライセンスを作成します。

適用対象

UnsignedPublishLicense(String)

指定した XrML 発行ライセンス テンプレートから、 クラスの UnsignedPublishLicense 新しいインスタンスを初期化します。

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)

パラメーター

publishLicenseTemplate
String

このライセンスの作成に使用する Extensible Rights Markup Language (XrML) 発行ライセンス テンプレート。

次の例は、このコンストラクターを使用する方法を示しています。

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

注釈

XrML <RANGETIME> または<INTERVALTIME>要素はpublishLicenseTemplate、(String) コンストラクターによって UnsignedPublishLicenseUnsignedPublishLicense作成されると無視されます。 発行ライセンスにこれらの値を指定するには、 と ValidUntil のプロパティValidFromContentGrant明示的に設定する必要があります。 次の例では、 プロパティと ValidUntil プロパティを明示的に設定する方法をValidFrom示します。

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

適用対象