My LicenseManager class for the Windows Phone

By Fons Sonnemans, posted on
2032 Views

I have developed a few Windows Phone apps which support a Trial mode. In these WP7 apps I use the static IsTrial property of my LicenseManager class to check if the user is using a paid or trial version. This class uses the IsTrial() method of the Microsoft.Phone.Marketplace.LicenseInformation class if you are running in configuration 'Release' mode. If you are developing and running in configuration 'Debug' mode it will return true if the TRIAL conditional compilation symbol is set in your project properties. This makes it easy to test the Trial mode in your code.

LicenseManager

    using System;
using Microsoft.Phone.Marketplace;

namespace ReflectionIT.TattooTester.Helpers {

    internalstaticclass LicenseManager {

        privatereadonlystaticbool _isTrial;

        static LicenseManager() {
#if DEBUG && TRIAL
            _isTrial = true;
#else
            _isTrial = new LicenseInformation().IsTrial();
#endif
        }

        publicstaticbool IsTrial {
            get { return _isTrial; }
        }

    }
}

Project Properties

If you want to test Trial mode add the TRIAL conditional compilation symbol. If not remove it or run in configuration 'Release' mode.

Cheers,

Fons

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.

Leave a comment

Blog comments

0 responses