dnauck / Portable.Licensing

Portable.Licensing is a cross platform software licensing framework which allows you to implement licensing into your application or library. It provides you all tools to create and validate licenses for your software.
http://dev.nauck-it.de/projects/portable-licensing
MIT License
592 stars 173 forks source link

Validation messages are not localizable #23

Closed makcakaya closed 9 years ago

makcakaya commented 9 years ago

For example, the message "Licensing for this product has expired!" is not appropriate if the application targets a different language.

Maybe validation should return an enumeration and we should use some kind of dictionary to get the message, and how to resolve information.

dnauck commented 9 years ago

Portable.Licensing has only default english locale strings. It has only two pre defined validation failures:

Both provide default english texts; but you can easily match their type and display your own localized text in your UI. I don't know why we need an extra enum here.

Maybe you can elaborate a bit more, please.

makcakaya commented 9 years ago

Hmm, so we should utilize the type like this:

var failures = _license.Validate().ExpirationDate().And().Signature(publicKey).AssertValidLicense();
foreach(var failure in failures)
{
    if(failure is LicenseExpiredValidationFailure){ .... }
    else if (failure is InvalidSignatureValidationFailure) {.....}
    else if (failure is GeneralValidationFailure) {..... } // general validation failure
    else { throw InvalidOperationException("Should not happen"); }
}

This solves my problem.