首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在C#中使用portable.licensing将‘company’添加到客户

在C#中使用portable.licensing将‘company’添加到客户
EN

Stack Overflow用户
提问于 2018-11-05 18:25:28
回答 1查看 403关注 0票数 3

我目前正在使用以下Portable.Licensing (https://github.com/dnauck/Portable.Licensing)代码构建许可证:

代码语言:javascript
复制
var license = Portable.Licensing.License.New();
license.WithUniqueIdentifier(guid);
license.As(Portable.Licensing.LicenseType.Standard);
license.LicensedTo(textBox_LicenseName.Text, textBox_LicenseEmail.Text);

函数LicensedTo()还有另一种定义,它接受一个额外的参数:

代码语言:javascript
复制
LicensedTo(string name, string email, Action<Customer> configureCustomer);

我如何使用这个额外的参数来包括“公司名称”以及名称和电子邮件?

EN

回答 1

Stack Overflow用户

发布于 2019-02-13 02:51:50

为此,请使用WithAdditionalAttributes

代码语言:javascript
复制
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);

并从生成的许可证中检索它:

代码语言:javascript
复制
var fs = new FileStream("license.lic", FileMode.Open);
var license = License.Load(fs);
var name = license.AdditionalAttributes.Get("CompanyName");
fs.Close();
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53152477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档