using System; using System.ComponentModel.Design; using System.Reflection; namespace System.ComponentModel { /// Provides properties and methods to add a license to a component and to manage a . This class cannot be inherited. // Token: 0x020000A0 RID: 160 public sealed class LicenseManager { // Token: 0x06000538 RID: 1336 RVA: 0x0000DD6C File Offset: 0x0000BF6C private LicenseManager() { } /// Gets or sets the current , which specifies when you can use the licensed object. /// A that specifies when you can use the licensed object. /// The property is currently locked and cannot be changed. /// /// /// // Token: 0x1700015C RID: 348 // (get) Token: 0x0600053A RID: 1338 RVA: 0x0000DD80 File Offset: 0x0000BF80 // (set) Token: 0x0600053B RID: 1339 RVA: 0x0000DDE4 File Offset: 0x0000BFE4 public static LicenseContext CurrentContext { get { object obj = LicenseManager.lockObject; LicenseContext licenseContext; lock (obj) { if (LicenseManager.mycontext == null) { LicenseManager.mycontext = new global::System.ComponentModel.Design.RuntimeLicenseContext(); } licenseContext = LicenseManager.mycontext; } return licenseContext; } set { object obj = LicenseManager.lockObject; lock (obj) { if (LicenseManager.contextLockUser != null) { throw new InvalidOperationException("The CurrentContext property of the LicenseManager is currently locked and cannot be changed."); } LicenseManager.mycontext = value; } } } /// Gets the which specifies when you can use the licensed object for the . /// One of the values, as specified in the property. // Token: 0x1700015D RID: 349 // (get) Token: 0x0600053C RID: 1340 RVA: 0x0000DE48 File Offset: 0x0000C048 public static LicenseUsageMode UsageMode { get { return LicenseManager.CurrentContext.UsageMode; } } /// Creates an instance of the specified type, given a context in which you can use the licensed instance. /// An instance of the specified type. /// A that represents the type to create. /// A that specifies when you can use the licensed instance. // Token: 0x0600053D RID: 1341 RVA: 0x0000DE54 File Offset: 0x0000C054 public static object CreateWithContext(Type type, LicenseContext creationContext) { return LicenseManager.CreateWithContext(type, creationContext, new object[0]); } /// Creates an instance of the specified type with the specified arguments, given a context in which you can use the licensed instance. /// An instance of the specified type with the given array of arguments. /// A that represents the type to create. /// A that specifies when you can use the licensed instance. /// An array of type that represents the arguments for the type. // Token: 0x0600053E RID: 1342 RVA: 0x0000DE64 File Offset: 0x0000C064 public static object CreateWithContext(Type type, LicenseContext creationContext, object[] args) { object obj = null; object obj2 = LicenseManager.lockObject; lock (obj2) { object obj3 = new object(); LicenseContext currentContext = LicenseManager.CurrentContext; LicenseManager.CurrentContext = creationContext; LicenseManager.LockContext(obj3); try { obj = Activator.CreateInstance(type, args); } catch (TargetInvocationException ex) { throw ex.InnerException; } finally { LicenseManager.UnlockContext(obj3); LicenseManager.CurrentContext = currentContext; } } return obj; } /// Returns whether the given type has a valid license. /// true if the given type is licensed; otherwise, false. /// The to find a valid license for. // Token: 0x0600053F RID: 1343 RVA: 0x0000DF1C File Offset: 0x0000C11C public static bool IsLicensed(Type type) { License license = null; if (!LicenseManager.privateGetLicense(type, null, false, out license)) { return false; } if (license != null) { license.Dispose(); } return true; } /// Determines whether a valid license can be granted for the specified type. /// true if a valid license can be granted; otherwise, false. /// A that represents the type of object that requests the . // Token: 0x06000540 RID: 1344 RVA: 0x0000DF4C File Offset: 0x0000C14C public static bool IsValid(Type type) { License license = null; if (!LicenseManager.privateGetLicense(type, null, false, out license)) { return false; } if (license != null) { license.Dispose(); } return true; } /// Determines whether a valid license can be granted for the specified instance of the type. This method creates a valid . /// true if a valid can be granted; otherwise, false. /// A that represents the type of object that requests the license. /// An object of the specified type or a type derived from the specified type. /// A that is a valid license, or null if a valid license cannot be granted. // Token: 0x06000541 RID: 1345 RVA: 0x0000DF7C File Offset: 0x0000C17C public static bool IsValid(Type type, object instance, out License license) { return LicenseManager.privateGetLicense(type, null, false, out license); } /// Prevents changes being made to the current of the given object. /// The object whose current context you want to lock. /// The context is already locked. // Token: 0x06000542 RID: 1346 RVA: 0x0000DF88 File Offset: 0x0000C188 public static void LockContext(object contextUser) { object obj = LicenseManager.lockObject; lock (obj) { LicenseManager.contextLockUser = contextUser; } } /// Allows changes to be made to the current of the given object. /// The object whose current context you want to unlock. /// /// represents a different user than the one specified in a previous call to . // Token: 0x06000543 RID: 1347 RVA: 0x0000DFD0 File Offset: 0x0000C1D0 public static void UnlockContext(object contextUser) { object obj = LicenseManager.lockObject; lock (obj) { if (LicenseManager.contextLockUser != null) { if (LicenseManager.contextLockUser != contextUser) { throw new ArgumentException("The CurrentContext property of the LicenseManager can only be unlocked with the same contextUser."); } LicenseManager.contextLockUser = null; } } } /// Determines whether a license can be granted for the specified type. /// A that represents the type of object that requests the license. /// A cannot be granted. // Token: 0x06000544 RID: 1348 RVA: 0x0000E03C File Offset: 0x0000C23C public static void Validate(Type type) { License license = null; if (!LicenseManager.privateGetLicense(type, null, true, out license)) { throw new LicenseException(type, null); } if (license != null) { license.Dispose(); } } /// Determines whether a license can be granted for the instance of the specified type. /// A valid . /// A that represents the type of object that requests the license. /// An of the specified type or a type derived from the specified type. /// The type is licensed, but a cannot be granted. // Token: 0x06000545 RID: 1349 RVA: 0x0000E070 File Offset: 0x0000C270 public static License Validate(Type type, object instance) { License license = null; if (!LicenseManager.privateGetLicense(type, instance, true, out license)) { throw new LicenseException(type, instance); } return license; } // Token: 0x06000546 RID: 1350 RVA: 0x0000E098 File Offset: 0x0000C298 private static bool privateGetLicense(Type type, object instance, bool allowExceptions, out License license) { bool flag = false; License license2 = null; LicenseProviderAttribute licenseProviderAttribute = (LicenseProviderAttribute)Attribute.GetCustomAttribute(type, typeof(LicenseProviderAttribute), true); if (licenseProviderAttribute != null) { Type licenseProvider = licenseProviderAttribute.LicenseProvider; if (licenseProvider != null) { LicenseProvider licenseProvider2 = (LicenseProvider)Activator.CreateInstance(licenseProvider); if (licenseProvider2 != null) { license2 = licenseProvider2.GetLicense(LicenseManager.CurrentContext, type, instance, allowExceptions); if (license2 != null) { flag = true; } } } } else { flag = true; } license = license2; return flag; } // Token: 0x04000182 RID: 386 private static LicenseContext mycontext; // Token: 0x04000183 RID: 387 private static object contextLockUser; // Token: 0x04000184 RID: 388 private static object lockObject = new object(); } }