Ejemplo n.º 1
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            // We'll test for the usage mode...run time v. design time. Note
            // we only check if run time...
            if (context.UsageMode == LicenseUsageMode.Runtime)
            {
                string strLic = LicenseUtil.readCurrentLicenseKey();

                if (strLic != null)
                {
                    // Trovato il codice di licenza. Ora provo a creare/generare una License vera e propria
                    RegistryLicense license = new RegistryLicense(strLic);
                    return(license);
                }

                // If we got this far, we failed the license test. We then
                // check to see if exceptions are allowed, and if so, throw
                // a new license exception...
                if (allowExceptions == true)
                {
                    throw new LicenseException(type, instance, "Your license is invalid");
                }

                // Exceptions are not desired, so we'll simply return null.
                return(null);
            }
            else
            {
                // return new DesigntimeRegistryLicense( type );
                return(null);
            }
        }