public static LicensingStatus GetLicenseByReflection(DocumentDatabase database) { var field = database.GetType().GetField("initializer", BindingFlags.Instance | BindingFlags.NonPublic); if (null == field) { throw new Exception("LicensingStatus failed"); } var initializer = field.GetValue(database); var validateLicenseField = initializer.GetType().GetField("validateLicense", BindingFlags.Instance | BindingFlags.NonPublic); if (null == validateLicenseField) { throw new Exception("LicensingStatus failed"); } var validateLicense = validateLicenseField.GetValue(initializer); var currentLicenseProp = validateLicense.GetType().GetProperty("CurrentLicense", BindingFlags.Static | BindingFlags.Public); if (null == currentLicenseProp) { throw new Exception("LicensingStatus failed"); } return((LicensingStatus)currentLicenseProp.GetValue(validateLicense, null)); }
public static LicensingStatus GetLicenseByReflection(DocumentDatabase database) { var field = database.GetType().GetField("validateLicense", BindingFlags.Instance | BindingFlags.NonPublic); Assert.NotNull(field); var validateLicense = field.GetValue(database); var currentLicenseProp = validateLicense.GetType().GetProperty("CurrentLicense", BindingFlags.Static | BindingFlags.Public); Assert.NotNull(currentLicenseProp); return((LicensingStatus)currentLicenseProp.GetValue(validateLicense, null)); }