# NetworkResurrector.Server.Wrapper

[NetworkResurrector.Server](https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector/src/branch/master/backend/src/server) is a .NET service designed to perform network-related actions such as **WakeOnLAN**, **Ping**, and **Shutdown** for machines within the same network or in networks where it has access.

**NetworkResurrector.Server.Wrapper** is a NuGet package that simplifies the integration of the server within a .NET environment. It registers a service, `IResurrectorService`, in the application's service collection, providing methods for each supported action. The package communicates with the server's API, offering a convenient interface for developers to manage the machines in the network through the server.

Once installed, the only additional step is to call the `UseResurrectorServices` method during application startup. After this, `IResurrectorService` can be injected into any class within the application.

## Features

- Simple integration with **NetworkResurrector.Server**.
- Provides easy-to-use methods for the machines in the network (WakeOnLAN, Ping, Shutdown).
- Registers `IResurrectorService` for dependency injection in the application.
- Facilitates communication with the server's API controller.

## Package Repository

You can install **NetworkResurrector.Server.Wrapper** from my self-hosted NuGet feed: [https://lab.code-rove.com/public-nuget-server/](https://lab.code-rove.com/public-nuget-server/)

## Installation

### Visual Studio

#### NuGet.config File

Add the following to your `NuGet.config` file:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="lab.nuget" value="https://lab.code-rove.com/public-nuget-server/v3/index.json" />
  </packageSources>
</configuration>
```
Place this file in your Visual Studio solution directory or configure the new NuGet feed in the NuGet Package Manager. After this, you can install **NetworkResurrector.Server.Wrapper** using the NuGet Package Manager.

### CLI
To install via the .NET CLI, run the following command in your project directory:
```bash
dotnet add package NetworkResurrector.Server.Wrapper --source https://lab.code-rove.com/public-nuget-server/v3/index.json
```

## Usage
Once installed, call the UseResurrectorServices method in your application startup code to register the service:

```csharp
public void ConfigureServices(IServiceCollection services)
{
    services.UseResurrectorServices();
}
```
After this, the `IResurrectorService` will be available for injection into any class:
```csharp
public class MyService
{
    private readonly IResurrectorService _resurrectorService;

    public MyService(IResurrectorService resurrectorService)
    {
        _resurrectorService = resurrectorService;
    }

    public void WakeMachine()
    {
        _resurrectorService.WakeMachine();
    }
}
```
