OpenLicenseBuilder 如何实施许可

发布于 2024-07-27 15:28:39 字数 1437 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风来 2024-08-03 15:28:39

读取源代码表明许可证提供者首先在内部缓存中查找,然后在隔离存储中查找。

同时,它尝试从文件系统获取许可证,如下所示(取决于它是 Web 应用程序还是 Windows 应用程序:

从一组预设路径获取许可证。路径定义为:

  • 应用程序 Bin 目录
  • 应用程序启动路径

In代码:

HttpContext.Current.Server.MapPath( "~" + Path.DirectorySeparatorChar );
HttpContext.Current.Server.MapPath( "." + Path.DirectorySeparatorChar );
HttpContext.Current.Server.MapPath( "~" + Path.DirectorySeparatorChar ) + "bin";

或者对于 Windows 应用程序:

System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar
System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar;

如果文件系统中的许可证比独立存储中的许可证更新,则会存储替代许可证的副本,

并且关于代码中的使用,该示例显示您需要使用该库。如下所示:

在类声明中使用属性来指示您将使用 OpenLicenseProvider 作为许可证提供程序:

using System.ComponentModel;
...

enter code here
[LicenseProvider( typeof( OpenLicense.OpenLicenseProvider ) )]
public class MyClass
{ 
    ...

然后在代码中使用 LicenseManager 通过 OpenLicenseProvider 验证许可证:

    private License license = null;

    LicenseManager.IsValid( typeof( MyClass ), this, out license );

Reading the source code indicates the Licensprovider first looks in an internal cache, secondly in the isolated storage.

At the same time it tries to fetch the license from the filesystem as follows (depending if it's a webapp or a windows app:

Obtains a license from a preset set of paths. The paths are defined as:

  • The Application Bin directory
  • Application start path

In code:

HttpContext.Current.Server.MapPath( "~" + Path.DirectorySeparatorChar );
HttpContext.Current.Server.MapPath( "." + Path.DirectorySeparatorChar );
HttpContext.Current.Server.MapPath( "~" + Path.DirectorySeparatorChar ) + "bin";

or for a windows app:

System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar
System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar;

if the license in the filesystem is newer then the license in the isolated storage, a copy of your alternative license is stored.

And concerning the usage in code. The example shows that you need to use the library as follows:

use an Attribute at the Class declaration to indicate that you will use the OpenLicenseProvider as the license provider:

using System.ComponentModel;
...

enter code here
[LicenseProvider( typeof( OpenLicense.OpenLicenseProvider ) )]
public class MyClass
{ 
    ...

Then in code use the LicenseManager to validate the license with OpenLicenseProvider:

    private License license = null;

    LicenseManager.IsValid( typeof( MyClass ), this, out license );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文