JereckNET.LicenseHerald
1.0.1
dotnet add package JereckNET.LicenseHerald --version 1.0.1
NuGet\Install-Package JereckNET.LicenseHerald -Version 1.0.1
<PackageReference Include="JereckNET.LicenseHerald" Version="1.0.1" />
paket add JereckNET.LicenseHerald --version 1.0.1
#r "nuget: JereckNET.LicenseHerald, 1.0.1"
// Install JereckNET.LicenseHerald as a Cake Addin
#addin nuget:?package=JereckNET.LicenseHerald&version=1.0.1
// Install JereckNET.LicenseHerald as a Cake Tool
#tool nuget:?package=JereckNET.LicenseHerald&version=1.0.1
User Guide
For the component developper
Once the LicenseHerald package is installed, you need to add a public resource file in your project, and a string resource containing the text of your license.
Finally, in your AssemblyInfo.cs
file (for .NET Framework), or in any code file (for .NET Standard), add a reference to the License Herald namespace and the ComponentHerald attribute :
using JereckNET.LicenseHerald;
...
[assembly: ComponentHerald("{Your project name}", typeof({YourComponentClass}), "{Your project homepage URL}", typeof({YourResourceClass}), nameof({YourResourceLicenseName}))]
Sample AssemblyInfo.cs
using JereckNET.LicenseHerald;
...
[assembly: ComponentHerald("My Project",
typeof(MyNamespace.MyProjectClass),
"https://www.exemple.com/MyProject",
typeof(MyProject.Properties.Resources),
nameof(MyProject.Properties.Resources.MyProject_License))]
For the component consumer
After installing the LicenseHerald package, you can call the extension method GetLicensedComponent()
added to the Assembly
class anywhere in your code.
That method will iterate through the target assembly and all of its referenced assemblies and will return a IList<LicensedComponent>
value.
The LicensedComponent
class has four public properties :
Name : The name of the component, as described in the component's assembly's ComponentHerald attribute. Version : The version of the component, directly extracted from the component's assembly. HomePage : The project homepage url, as described in the component's assembly's ComponentHerald attribute. License : The text of the component's license, extracted from the component's public resource.
Sample consumer usage
As GetLicensedComponent()
returns an IList
object, it can be used to fill a drop-down list through its DataSource property.
using JereckNET.LicenseHerald;
...
public Form1(){
var components = Assembly.GetExecutingAssembly().GetLicensedComponent();
comboBox1.DataSource = components;
}
...
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) {
LicensedComponent component = comboBox1.SelectedItem as LicensedComponent;
label1.Text = component.Version.ToString();
linkLabel1.Text = component.HomePage;
linkLabel1.Links.Clear();
linkLabel1.Links.Add(new LinkLabel.Link {
LinkData = component.HomePage
});
textBox1.Text = component.License;
}
Components not using LicenceHerald
Let's be honest : not everyone is already using LicenseHerald (as of this writing, there is a total of one component : this one).
It is possible for a developer to add a LicensedComponent for an external component to his/her project by adding any number of ComponentHeraldAttribute
to the project's AssemblyInfo.cs
file.
The components declared within the executing assembly (i.e. your project's application assembly) will also be returned by GetLicensedComponent()
.
Sample with Newtonsoft.Json
using JereckNET.LicenseHerald;
...
[assembly:ComponentHerald(
"Newtonsoft.Json",
typeof(Newtonsoft.Json.JsonConvert), // Can reference any type from the external component
"https://www.newtonsoft.com/json",
typeof(MyProject.Properties.Resources),
nameof(MyProject.Properties.Resources.NewtonsoftJsonLicence)
)]
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 553 | 7/11/2019 |
Added project Icon, added support for external components