我想保存许可证到一个文件中,像这样:Portable.Licensing - 节能许可文件
File.WriteAllText(theSaveFileDialogBox.FileName, license.ToString(), Encoding.UTF8);
的建议在这里:
http://dev.nauck-it.de/projects/portable-licensing/wiki/GettingStarted
但内容我保存文件总是最后只是
Portable.Licensing.LicenseBuilder
就好像ToString()
方法没有被覆盖。此外,Save()
方法甚至不会以license
的成员身份出现。有任何想法吗?
更新:
的问题是,我试图建立由部分许可了,因为这样的:
var license = Portable.Licensing.License.New().WithUniqueIdentifier(Guid.NewGuid());
if (lic_type_box.Text == "Trial") license.As(LicenseType.Trial);
else if (lic_type_box.Text == "Full") license.As(LicenseType.Standard);
int days;
if (int.TryParse(lic_days.Text, out days)) license.ExpiresAt(DateTime.Now.AddDays(days));
if (lic_name.Text != "") license.LicensedTo("lic_name.Text", "");
license.CreateAndSignWithPrivateKey(privateKey, passPhrase);
当最后一行应该真的已经
var createdLicense = license.CreateAndSignWithPrivateKey(privateKey, passPhrase);
然后
File.WriteAllText(theSaveFileDialogBox.FileName, createdLicense.ToString(), Encoding.UTF8);
哇,伟大的工作调试。谢谢 - 我没有意识到'CreateAndSignWithPrivateKey()'方法正在返回一个新的对象。 – dashnick
对不起,这个答案有点难以遵循..当我导航github和他们的教程时,我的大脑转储。很高兴排序。 – Nico