我试图将许可保存到这样的文件中:
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);发布于 2017-02-27 00:03:19
我从来没有实际使用过这个库,但是Portable.Licensing.LicenseBuilder (可能)是license.ToString()的结果。
看看他们的教程,他们实际上是在调用CreateAndSignWithPrivateKey(..,...)方法,这是一个返回License而不是LicenseBuilder实例的方法。
这是关键,因为License类重写ToString()方法并返回从许可证生成器类的结果生成的xml数据。
对,这看起来有点复杂,但基本上License.New()返回一个ILicenseBuilder。这没有Save方法,但是License有。\
现在,我们将尽可能多地帮助您,因为您需要为我们提供一些代码,说明license到底是什么。
https://stackoverflow.com/questions/42475605
复制相似问题