다음을 통해 공유


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

이 라이선스를 만드는 데 사용할 XrML(Extensible Rights Markup Language) 게시 라이선스 템플릿입니다.

예제

다음 예제에서는 이 생성자를 사용하는 방법을 보여 줍니다.

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

설명

publishLicenseTemplate XrML <RANGETIME> 또는 <INTERVALTIME> 요소는 (String) 생성자에 의해 UnsignedPublishLicense생성될 때 UnsignedPublishLicense 무시됩니다. 게시 라이선스에 대 한 이러한 값을 지정 하는 ContentGrant 속성에 대 한 ValidFromValidUntil 명시적으로 설정 해야 합니다. 다음 예제에서는 명시적으로 설정 하는 방법을 보여 줍니다 합니다 ValidFromValidUntil 속성입니다.

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

적용 대상