LicFileLicenseProvider.GetLicense(LicenseContext, Type, Object, Boolean) Метод
Определение
Возвращает лицензию для экземпляра компонента, если она доступна.Returns a license for the instance of the component, if one is available.
public:
override System::ComponentModel::License ^ GetLicense(System::ComponentModel::LicenseContext ^ context, Type ^ type, System::Object ^ instance, bool allowExceptions);
public override System.ComponentModel.License GetLicense (System.ComponentModel.LicenseContext context, Type type, object instance, bool allowExceptions);
override this.GetLicense : System.ComponentModel.LicenseContext * Type * obj * bool -> System.ComponentModel.License
Public Overrides Function GetLicense (context As LicenseContext, type As Type, instance As Object, allowExceptions As Boolean) As License
Параметры
- context
- LicenseContext
Объект LicenseContext, определяющий, где можно использовать лицензированный объект.A LicenseContext that specifies where you can use the licensed object.
- type
- Type
Объект Type, представляющий компонент, запрашивающий лицензию License.A Type that represents the component requesting the License.
- allowExceptions
- Boolean
Значение true
, если исключение LicenseException должно вызываться, когда компоненту не может быть предоставлена лицензия; в противном случае — значение false
.true
if a LicenseException should be thrown when a component cannot be granted a license; otherwise, false
.
Возвращаемое значение
Допустимый класс License.A valid License. Если этот метод не может найти действительную лицензию License или действительный параметр context
, возвращается значение null
.If this method cannot find a valid License or a valid context
parameter, it returns null
.
Комментарии
Во время разработки GetLicense метод ищет файл лицензии с именем myClassName.LIC
, где myClassName
— FullName создаваемый компонент.At design time, the GetLicense method looks for a license file named myClassName.LIC
, where myClassName
is the FullName of the component to create. Этот файл должен находиться в том же каталоге, что и DLL-файл, содержащий компонент.This file must be in the same directory as the .dll file that contains the component.
Затем этот метод проверяет первую строку файла лицензии на соответствие ключу, указанному в IsKeyValid методе.Next, this method checks the first line of the license file against a key specified in the IsKeyValid method. Если ключ допустим, эта строка используется как LicenseKey .If the key is valid, this line is used as the LicenseKey.