Mtf.Network.Interfaces
1.0.3
See the version list below for details.
dotnet add package Mtf.Network.Interfaces --version 1.0.3
NuGet\Install-Package Mtf.Network.Interfaces -Version 1.0.3
<PackageReference Include="Mtf.Network.Interfaces" Version="1.0.3" />
<PackageVersion Include="Mtf.Network.Interfaces" Version="1.0.3" />
<PackageReference Include="Mtf.Network.Interfaces" />
paket add Mtf.Network.Interfaces --version 1.0.3
#r "nuget: Mtf.Network.Interfaces, 1.0.3"
#:package Mtf.Network.Interfaces@1.0.3
#addin nuget:?package=Mtf.Network.Interfaces&version=1.0.3
#tool nuget:?package=Mtf.Network.Interfaces&version=1.0.3
Mtf.Network.Interfaces Library Documentation
Overview
The Mtf.Network.Interfaces
namespace defines key interfaces used for modular development in the Mtf.Network
ecosystem. These interfaces cover cryptographic operations, image acquisition, process output handling, and screen-related utilities, enabling extensibility and platform abstraction.
This document details each interface, its purpose, method signatures, and example use cases.
Interface: ICipher
The ICipher
interface defines methods for symmetric or asymmetric encryption and decryption of strings and byte arrays.
Methods
Method | Return Type | Description |
---|---|---|
Encrypt(string plainText) |
string |
Encrypts a plaintext string and returns the ciphertext as a string. |
Decrypt(string cipherText) |
string |
Decrypts the encrypted string back into plaintext. |
Encrypt(byte[] plainBytes) |
byte[] |
Encrypts a byte array and returns the encrypted byte array. |
Decrypt(byte[] cipherBytes) |
byte[] |
Decrypts the byte array and returns the original data. |
Example Implementation
public class CaesarCipher : ICipher
{
public string Encrypt(string plainText) => new string(plainText.Select(c => (char)(c + 3)).ToArray());
public string Decrypt(string cipherText) => new string(cipherText.Select(c => (char)(c - 3)).ToArray());
public byte[] Encrypt(byte[] plainBytes) => plainBytes.Select(b => (byte)(b + 3)).ToArray();
public byte[] Decrypt(byte[] cipherBytes) => cipherBytes.Select(b => (byte)(b - 3)).ToArray();
}
Interface: IImageSource
The IImageSource
interface abstracts the mechanism for capturing image data asynchronously, typically from a video source or screen.
Methods
Method | Return Type | Description |
---|---|---|
CaptureAsync(CancellationToken token) |
Task<byte[]> |
Captures a frame and returns the result as a byte array. The operation can be canceled via the token. |
Example Usage
public class DummyCamera : IImageSource
{
public Task<byte[]> CaptureAsync(CancellationToken token)
{
var dummyImage = new byte[] { 0xFF, 0xD8, 0xFF }; // JPEG header as example
return Task.FromResult(dummyImage);
}
}
Interface: IProcessResultParser
The IProcessResultParser
interface provides hooks for reading and processing output and error streams from external processes, commonly used with Process.Start
.
Methods
Method | Parameters | Description |
---|---|---|
ErrorDataReceived(object sender, DataReceivedEventArgs e) |
sender : the process; e : error line |
Called when a line is received on the error stream. |
OutputDataReceived(object sender, DataReceivedEventArgs e) |
sender : the process; e : output line |
Called when a line is received on the standard output. |
Example Usage
public class ConsoleProcessLogger : IProcessResultParser
{
public void ErrorDataReceived(object sender, DataReceivedEventArgs e) => Console.Error.WriteLine(e.Data);
public void OutputDataReceived(object sender, DataReceivedEventArgs e) => Console.WriteLine(e.Data);
}
Interface: IScreenInfoProvider
The IScreenInfoProvider
interface provides information about a screen device, including its dimensions and ID.
Properties & Methods
Member | Return Type | Description |
---|---|---|
Id |
string |
A unique identifier for the screen (e.g., "\\.\DISPLAY1" ). |
GetBounds() |
Rectangle |
Returns the bounding rectangle of the screen. |
GetPrimaryScreenSize() |
Size |
Returns the size of the primary screen (regardless of the current screen). |
Example Implementation
public class WindowsScreenInfoProvider : IScreenInfoProvider
{
public string Id => Screen.PrimaryScreen.DeviceName;
public Rectangle GetBounds() => Screen.PrimaryScreen.Bounds;
public Size GetPrimaryScreenSize() => Screen.PrimaryScreen.Bounds.Size;
}
Summary
These interfaces in Mtf.Network.Interfaces
offer a clean and flexible foundation for:
- ICipher: Cryptographic transformation abstraction.
- IImageSource: Capturing images from dynamic sources.
- IProcessResultParser: Parsing stdout/stderr of subprocesses.
- IScreenInfoProvider: Retrieving monitor/screen info.
They are designed to facilitate testable, maintainable, and scalable applications using composition and dependency injection.
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 is compatible. 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. |
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Mtf.Network.Interfaces:
Package | Downloads |
---|---|
Mtf.Network
TCP-based clients are designed to help understand the basics of network communication. These clients do not encrypt the data they send. I recommend not using them in commercial applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.