Skip to content

PeernetOfficial/SDK

Repository files navigation

Peernet SDK

Peernet SDK (Peernet.SDK) is a Class Library project targetting .NET 6.0. The SDK is devided into few parts. One part is Models which is set of plugin interfaces, domain and presentation models.
Presentation models are used among presentation part of the Peernet Browser. They define objects living in the User Interface.
Domain models are objects representing structures returned from the backend. They are mainly needed for the second part of the SDK, which is Client.
Client is set of APIs for Backend communication. Single PeernetClient object gathers all functionalities in one place.
Last part of the SDK are Common objects. These are objects shared within the system, e.g. ISettingsManager which gives access to application settings.

Usage

Peernet SDK solution builds into a single library Peernet.SDK.dll. To develop .NET solution for the Peernet system all you need to do is to reference the library (See details).

<ItemGroup>
	<Reference Include="Peernet.SDK">
		<HintPath>..\..\Peernet.SDK.dll</HintPath>
	</Reference>
</ItemGroup>

Peernet SDK is used in Peernet Browser as well as Peernet Plugins.

If you are using IoC container in your solution you can use RegisterPeernetClients extension method from Peernet.SDK.Client.Extensions namespace.

Action<HttpResponseMessage, string> onRequestFailure =
    (response, details) => notificationsManager?.Notifications.Add(
        new($"Unexpected response status code: {response.StatusCode}", details, Severity.Error));
services.RegisterPeernetClients(() => settings.ApiUrl, settings.ApiKey, onRequestFailure);

Otherwise you should construct new PeernetClient object for backend interactions.

Plugins Template

Plugins Template (Peernet.Browser.Plugins.Template) is a Class Library project targetting .NET 5.0 with WPF features enabled. The project essentials are:

  • Peernet.SDK dependency
  • Plugin interfaces implementation

The template project consist of few sample classes:

  • SamplePlugin implementing IPlugin interface.
  • SampleService implementing IPlayButtonPlug.
  • SampleGenericWindow and SampleWindow which demonstrate some use cases and are optional.
  • SampleGenericViewModel and SampleViewModel which are ViewModels for Windows mentioned above whereas SampleGenericViewModel differs from a regular ViewModelBase descendants with its ability to pass a parameter to a ViewModel.

To find out how particular interfaces are utilized within UI check the Peernet Browser documentation.

Plugin development

To develop your own plugin its recommanded to use a copy of the Peernet.Browser.Plugins.Template solution. You can either modify and extend sample classes accordingly to your needs or clean up the template and start from scratch. If you decide to develop the plugin from the beginning remember about essentials.
Peernet.SDK needs to be compatible with the version of Peernet Browser to which you would like to plug in. Differences in Models or Client incompatible with current Backend version may result in runtime errors.
Your plugin's most important class is the one implementing IPlugin interface, without it Peernet Browser won't load your plugin.
The purpose of IPlugin interface is to allow the plugin to access the IoC Container to register all required services and pluggable interfaces implementation.
The IPlayButtonPlug interface is one of pluggable interfaces for the Peernet Browser customization. It is the interface for the Play button available on Search & Explore & Directory Tab data grid rows. It exposes Execute method which is invoked whenever the button is clicked.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published