Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
275 lines (262 sloc) 17.5 KB
<Type Name="LicFileLicenseProvider" FullName="System.ComponentModel.LicFileLicenseProvider">
<TypeSignature Language="C#" Value="public class LicFileLicenseProvider : System.ComponentModel.LicenseProvider" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit LicFileLicenseProvider extends System.ComponentModel.LicenseProvider" />
<TypeSignature Language="DocId" Value="T:System.ComponentModel.LicFileLicenseProvider" />
<TypeSignature Language="VB.NET" Value="Public Class LicFileLicenseProvider&#xA;Inherits LicenseProvider" />
<TypeSignature Language="C++ CLI" Value="public ref class LicFileLicenseProvider : System::ComponentModel::LicenseProvider" />
<TypeSignature Language="F#" Value="type LicFileLicenseProvider = class&#xA; inherit LicenseProvider" />
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.TypeConverter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.ComponentModel.LicenseProvider</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides an implementation of a <see cref="T:System.ComponentModel.LicenseProvider" />. The provider works in a similar fashion to the Microsoft .NET Framework standard licensing model.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.ComponentModel.LicFileLicenseProvider> offers <xref:System.ComponentModel.LicFileLicenseProvider.GetLicense%2A> and <xref:System.ComponentModel.LicFileLicenseProvider.IsKeyValid%2A> methods. The <xref:System.ComponentModel.LicFileLicenseProvider.IsKeyValid%2A> method determines whether the <xref:System.ComponentModel.License.LicenseKey%2A> retrieved by the <xref:System.ComponentModel.LicFileLicenseProvider.GetLicense%2A> method is valid. When you inherit from this class, you can override the <xref:System.ComponentModel.LicFileLicenseProvider.IsKeyValid%2A> method to provide your own validation logic.
This class exists to provide similar licensing functionality to COM licensing and uses text license files.
For more information on licensing, see [How to: License Components and Controls](https://msdn.microsoft.com/library/8e66c1ed-a445-4b26-8185-990b6e2bbd57).
## Examples
The following example creates a licensed control using the <xref:System.ComponentModel.LicenseManager.Validate%2A> method. It uses <xref:System.ComponentModel.LicFileLicenseProvider> for the license manager.
[!code-cpp[Classic LicenseManager Example#1](~/samples/snippets/cpp/VS_Snippets_Winforms/Classic LicenseManager Example/CPP/source.cpp#1)]
[!code-csharp[Classic LicenseManager Example#1](~/samples/snippets/csharp/VS_Snippets_Winforms/Classic LicenseManager Example/CS/source.cs#1)]
[!code-vb[Classic LicenseManager Example#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/Classic LicenseManager Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.ComponentModel.License" />
<altmember cref="T:System.ComponentModel.LicenseContext" />
<altmember cref="T:System.ComponentModel.LicenseException" />
<altmember cref="T:System.ComponentModel.LicenseManager" />
<altmember cref="T:System.ComponentModel.LicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseProviderAttribute" />
<altmember cref="T:System.ComponentModel.LicFileLicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseUsageMode" />
<related type="Article" href="https://msdn.microsoft.com/library/8e66c1ed-a445-4b26-8185-990b6e2bbd57">How to: License Components and Controls</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public LicFileLicenseProvider ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.LicFileLicenseProvider.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; LicFileLicenseProvider();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.TypeConverter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.ComponentModel.LicFileLicenseProvider" /> class.</summary>
<remarks>To be added.</remarks>
<altmember cref="T:System.ComponentModel.License" />
<altmember cref="T:System.ComponentModel.LicenseContext" />
<altmember cref="T:System.ComponentModel.LicenseException" />
<altmember cref="T:System.ComponentModel.LicenseManager" />
<altmember cref="T:System.ComponentModel.LicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseProviderAttribute" />
<altmember cref="T:System.ComponentModel.LicFileLicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseUsageMode" />
<related type="Article" href="https://msdn.microsoft.com/library/8e66c1ed-a445-4b26-8185-990b6e2bbd57">How to: License Components and Controls</related>
</Docs>
</Member>
<Member MemberName="GetKey">
<MemberSignature Language="C#" Value="protected virtual string GetKey (Type type);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance string GetKey(class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.LicFileLicenseProvider.GetKey(System.Type)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual System::String ^ GetKey(Type ^ type);" />
<MemberSignature Language="F#" Value="abstract member GetKey : Type -&gt; string&#xA;override this.GetKey : Type -&gt; string" Usage="licFileLicenseProvider.GetKey type" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.TypeConverter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="type">The object type to return the key.</param>
<summary>Returns a key for the specified type.</summary>
<returns>A confirmation that the <paramref name="type" /> parameter is licensed.</returns>
<remarks>To be added.</remarks>
<altmember cref="T:System.ComponentModel.License" />
<altmember cref="T:System.ComponentModel.LicenseContext" />
<altmember cref="T:System.ComponentModel.LicenseException" />
<altmember cref="T:System.ComponentModel.LicenseManager" />
<altmember cref="T:System.ComponentModel.LicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseProviderAttribute" />
<altmember cref="T:System.ComponentModel.LicFileLicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseUsageMode" />
<related type="Article" href="https://msdn.microsoft.com/library/8e66c1ed-a445-4b26-8185-990b6e2bbd57">How to: License Components and Controls</related>
</Docs>
</Member>
<Member MemberName="GetLicense">
<MemberSignature Language="C#" Value="public override System.ComponentModel.License GetLicense (System.ComponentModel.LicenseContext context, Type type, object instance, bool allowExceptions);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance class System.ComponentModel.License GetLicense(class System.ComponentModel.LicenseContext context, class System.Type type, object instance, bool allowExceptions) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.LicFileLicenseProvider.GetLicense(System.ComponentModel.LicenseContext,System.Type,System.Object,System.Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override System::ComponentModel::License ^ GetLicense(System::ComponentModel::LicenseContext ^ context, Type ^ type, System::Object ^ instance, bool allowExceptions);" />
<MemberSignature Language="F#" Value="override this.GetLicense : System.ComponentModel.LicenseContext * Type * obj * bool -&gt; System.ComponentModel.License" Usage="licFileLicenseProvider.GetLicense (context, type, instance, allowExceptions)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.TypeConverter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.ComponentModel.License</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="context" Type="System.ComponentModel.LicenseContext" />
<Parameter Name="type" Type="System.Type" />
<Parameter Name="instance" Type="System.Object" />
<Parameter Name="allowExceptions" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="context">A <see cref="T:System.ComponentModel.LicenseContext" /> that specifies where you can use the licensed object.</param>
<param name="type">A <see cref="T:System.Type" /> that represents the component requesting the <see cref="T:System.ComponentModel.License" />.</param>
<param name="instance">An object that requests the <see cref="T:System.ComponentModel.License" />.</param>
<param name="allowExceptions">
<see langword="true" /> if a <see cref="T:System.ComponentModel.LicenseException" /> should be thrown when a component cannot be granted a license; otherwise, <see langword="false" />.</param>
<summary>Returns a license for the instance of the component, if one is available.</summary>
<returns>A valid <see cref="T:System.ComponentModel.License" />. If this method cannot find a valid <see cref="T:System.ComponentModel.License" /> or a valid <paramref name="context" /> parameter, it returns <see langword="null" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
At design time, the <xref:System.ComponentModel.LicFileLicenseProvider.GetLicense%2A> method looks for a license file named `myClassName.LIC`, where `myClassName` is the <xref:System.Type.FullName%2A> of the component to create. This file must be in the same directory as the .dll file that contains the component.
Next, this method checks the first line of the license file against a key specified in the <xref:System.ComponentModel.LicFileLicenseProvider.IsKeyValid%2A> method. If the key is valid, this line is used as the <xref:System.ComponentModel.License.LicenseKey%2A>.
]]></format>
</remarks>
<altmember cref="T:System.ComponentModel.License" />
<altmember cref="T:System.ComponentModel.LicenseContext" />
<altmember cref="T:System.ComponentModel.LicenseException" />
<altmember cref="T:System.ComponentModel.LicenseManager" />
<altmember cref="T:System.ComponentModel.LicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseProviderAttribute" />
<altmember cref="T:System.ComponentModel.LicFileLicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseUsageMode" />
<related type="Article" href="https://msdn.microsoft.com/library/8e66c1ed-a445-4b26-8185-990b6e2bbd57">How to: License Components and Controls</related>
</Docs>
</Member>
<Member MemberName="IsKeyValid">
<MemberSignature Language="C#" Value="protected virtual bool IsKeyValid (string key, Type type);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool IsKeyValid(string key, class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.LicFileLicenseProvider.IsKeyValid(System.String,System.Type)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual bool IsKeyValid(System::String ^ key, Type ^ type);" />
<MemberSignature Language="F#" Value="abstract member IsKeyValid : string * Type -&gt; bool&#xA;override this.IsKeyValid : string * Type -&gt; bool" Usage="licFileLicenseProvider.IsKeyValid (key, type)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.TypeConverter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.String" />
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="key">The <see cref="P:System.ComponentModel.License.LicenseKey" /> to check.</param>
<param name="type">A <see cref="T:System.Type" /> that represents the component requesting the <see cref="T:System.ComponentModel.License" />.</param>
<summary>Determines whether the key that the <see cref="M:System.ComponentModel.LicFileLicenseProvider.GetLicense(System.ComponentModel.LicenseContext,System.Type,System.Object,System.Boolean)" /> method retrieves is valid for the specified type.</summary>
<returns>
<see langword="true" /> if the key is a valid <see cref="P:System.ComponentModel.License.LicenseKey" /> for the specified type; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method checks the key against the phrase: " `myClassName is a licensed component.` ", where `myClassName` is the <xref:System.Type.FullName%2A> of the component you want to create.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When you inherit from this class, you can override this method to provide your own validation logic.</para>
</block>
<altmember cref="T:System.ComponentModel.License" />
<altmember cref="T:System.ComponentModel.LicenseContext" />
<altmember cref="T:System.ComponentModel.LicenseException" />
<altmember cref="T:System.ComponentModel.LicenseManager" />
<altmember cref="T:System.ComponentModel.LicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseProviderAttribute" />
<altmember cref="T:System.ComponentModel.LicFileLicenseProvider" />
<altmember cref="T:System.ComponentModel.LicenseUsageMode" />
<related type="Article" href="https://msdn.microsoft.com/library/8e66c1ed-a445-4b26-8185-990b6e2bbd57">How to: License Components and Controls</related>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.