我目前正在使用以下Portable.Licensing (https://github.com/dnauck/Portable.Licensing)代码构建许可证:
var license = Portable.Licensing.License.New();
license.WithUniqueIdentifier(guid);
license.As(Portable.Licensing.LicenseType.Standard);
license.LicensedTo(textBox_LicenseName.Text, textBox_LicenseEmail.Text);函数LicensedTo()还有另一种定义,它接受一个额外的参数:
LicensedTo(string name, string email, Action<Customer> configureCustomer);我如何使用这个额外的参数来包括“公司名称”以及名称和电子邮件?
发布于 2019-02-13 02:51:50
为此,请使用WithAdditionalAttributes:
var license = License.New()
.WithUniqueIdentifier(Guid.NewGuid())
//Look here
.WithAdditionalAttributes(new Dictionary<string, string>
{
{"CompanyName", companyName }
})
.As(LicenseType.Trial)
.ExpiresAt(DateTime.Now.AddDays(30))
.WithMaximumUtilization(numberOfUsers)
.LicensedTo(licensedTo, contactEmail)
.CreateAndSignWithPrivateKey(privateKey, passPhrase);并从生成的许可证中检索它:
var fs = new FileStream("license.lic", FileMode.Open);
var license = License.Load(fs);
var name = license.AdditionalAttributes.Get("CompanyName");
fs.Close();https://stackoverflow.com/questions/53152477
复制相似问题