public void License(SC.Interfaces.ILicensee licensee) { if (RequiresLicense(licensee)) { Guid guid = Guid.NewGuid(); while (licenses.ContainsKey(guid) || guid == Guid.Empty) guid = Guid.NewGuid(); SC.Interfaces.LicenseRequest req = GetLicenseRequest(licensee.GetType()); string licName = req.LicenseName; bool valid = false; while (req != null) { if (licenseinfos.ContainsKey(req.LicenseName)) { LicenseInfo info = licenseinfos[req.LicenseName]; if (!(valid = info.Count > GetUsedLicenseCount(req.LicenseName))) { valid = false; break; } else if (info.IsValid) { req = null; } } else { valid = false; req = null; } } if (valid) { Logger.Info("Granting license " + licName + " to " + licensee.ToString()); License lic = new License(guid, licName); licensee.AssignLicense(lic); licenses.Add(guid, lic); } else { Logger.Info("No license " + licName + " available for " + licensee.ToString()); licensee.AssignLicense(new License(Guid.Empty, licName)); } } }