When using the declarative licensing approach, you select methods to be protected and optionally licensed by marking the methods with the appropriate protection attribute in source code. Whenever your application is built, the selected methods will be automatically protected during the Code Protection phase.
Protection Attribute
Methods marked with the [Protect]
attribute (use <Protect> for VB projects) will be automatically protected without licensing during the Code Protection phase whenever the application is built.
Licensing Attribute
One can additionally indicate that the protected method will require a license before it can be executed. You can also associate the method a specific feature; this means that to execute the method a valid license must include the required feature.
With SpAgent, the set of available licensing attributes are generated automatically when you install the SoftwarePotential-Licensing package in your solution. The attributes are of the form:
[<ProductName_Vers>.License]
: - this attribute indicates a valid license is required to execute the method. The method is not associated with any specific product feature.[<ProductName_Vers>.Features.<FeatureName>]
: - this attribute indicates a valid license is required to execute a method AND the specified feature must be included in the license.
For VB projects use <> brackets in place of [] brackets.
Implementation
The following is an example of how to use attributes to select licenses to be protected and licensed, including being associated with a specific product feature. This code is being licensed against a version 1.0 of a product named "MyApp" defined in Software Potential service.
using Slps.ProtectionAttributes; public class MyCode { public void WillNotBeProtectedUnlessOneChecksTheMethodInCodeProtector() { } [Protect] //use for VB projects public void WillBeProtectedWithoutLicensing() { } [MyApp_10.License] //use for VB projects public void WillBeLicensedButNotTiedToASpecificFeature() { } [MyApp_10.Features.Feature1] //use <MyApp_10.Features.Feature1)> for VB projects public void WillBeLicensedAndTiedToFeatureA() { } }
Comments
0 comments
Article is closed for comments.