我正在某些项目上。我所需要的就是仅向一台计算机提供该产品的许可证,因此我添加了一个如图3所示的附加属性硬件ID。我该如何验证它。在这方面帮助我。谢谢..

var license = Portable.Licensing.License.New()
                   .WithUniqueIdentifier(Guid.NewGuid())
                   .As(Portable.Licensing.LicenseType.Trial)
                   .ExpiresAt(DateTime.Now.AddDays(5))
                   .WithMaximumUtilization(Int32.Parse(User.Text))
                   .WithAdditionalAttributes(new Dictionary<String,String>{
                                               {"Hardware ID","12343"}
                                                })
                   .LicensedTo(name.Text, email.Text)
                   .CreateAndSignWithPrivateKey(privateKey, "212555555");

最佳答案

好吧,我找到了这个非常简单的答案。

  • 使用Portable.Licencing提供的AssertThat()方法。
    前任:-
            var validationFailures = licenseContent.Validate()
            .ExpirationDate()
            .When(lic => lic.Type == Portable.Licensing.LicenseType.Trial)
            .And()
            .AssertThat(lic => lic.Quantity >= 3, failure1)
            .And()
            .AssertThat(lic => lic.ProductFeatures.Get("HardwareID") == "133456", failure1)
            .When(lic => lic.ProductFeatures.Contains("HardwareID"))
            .And()
            .Signature(publicKey)
            .AssertValidLicense().ToList();
    
  • 编写您自己的验证案例。
  • 关于c# - 使用Portable.Licensing如何验证属性硬件ID,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35450455/

    10-17 02:16