Class AssemblyLicenseLoaderAttribute
Specifies the assembly license loader.
Inheritance
Implements
Inherited Members
Namespace: DevZest.Licensing
Assembly: DevZest.Licensing.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class AssemblyLicenseLoaderAttribute : Attribute, _Attribute
Remarks
If AssemblyLicenseLoaderAttribute does not exist for the caller assembly, the assembly license is retrieved from the embedded resource of the caller assembly. The name of the embedded resource must end with the value returned by GetAssemblyLicenseFileName(AssemblyName)
If AssemblyLicenseLoaderAttribute exists for the caller assembly, a IAssemblyLicenseLoader instance of LoaderType will be created to retrieve the assembly license. This allows the caller assembly to customize the storage of the assembly license.
The following example loads the assembly file from the application root directory:
[assembly: DevZest.Licensing.EmbeddedAssemblyLicense(typeof(LicenseLoader))]
class LicenseLoader : IAssemblyLicenseLoader
{
public string Load(System.Reflection.Assembly assembly)
{
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AssemblyLicenseProviderAttribute.GetAssemblyLicenseFileName(assembly.GetName()));
if (!File.Exists(filePath))
return null;
return File.ReadAllText(filePath);
}
}
<Assembly: DevZest.Licensing.EmbeddedAssemblyLicense(GetType(MyAssemblyLic.Class1))>
Class LicenseLoader
Implements IAssemblyLicenseLoader
Public Function Load(ByVal assembly As System.Reflection.Assembly) As String
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AssemblyLicenseProviderAttribute.GetAssemblyLicenseFileName(assembly.GetName))
If Not File.Exists(filePath) Then
Return Nothing
End If
Return File.ReadAllText(filePath)
End Function
End Class
Constructors
Name | Description |
---|---|
AssemblyLicenseLoaderAttribute(Type) | Initializes a new instance of AssemblyLicenseLoaderAttribute. |
Properties
Name | Description |
---|---|
LoaderType | Gets the type that implements IAssemblyLicenseLoader. |