I'm using a third party library, and as part of its requirements, I need to register a license key to it, before using it.
To help do this, I was thinking of having a helper class of form:
namespace SomeLibrary
{
public static class LibraryHelper
{
public static void RegisterLicense()
{
}
static LibraryHelper()
{
// call underlying library's code to register. Should only be called once.
TheThirdPartyLibrary.RegisterLicenceKey("ABC");
}
}
}
Then in the startup of my application (e.g. in Program.cs), I could call:
SomeLibrary.LibraryHelper.RegisterLicense().
The static constructor is just to ensure that TheThirdPartyLibrary.RegisterLicenceKey("ABC");
does not get called more than once. My understanding is that this should work, but the code looks a bit unusual having a RegisterLicense method that is empty.
Are there any other alternatives ?