I’m writing a class library for licensing which is going to be referenced by an application. Now i need to return a wide range of responses like error connecting to the server, temporary license detected, demo going on, demo expired, licensed version, license expired, license renewed etc. What is the best method to return these responses other than sending it as a plain string value?
Thank you.
Here’s my suggestions:
1.You can return an object that has a message and a type.
2.You can have a base class and inherit different classes from it that are different type of responses.
for example:
`public abstract class LicenseType
{
public abstract string Message{get;}
}
public class DemoLicensed:LicenseType
{
public override string Message
{
return “Demo Licensed”;
}
}
`
3.if something goes wrong with your licensing service I suggest you throw an exception instead of returning a response.