Mark exposed fields and methods

This commit is contained in:
2024-02-12 02:01:31 +01:00
parent cbca4fd7de
commit bb8959160a
10 changed files with 23 additions and 15 deletions

View File

@ -8,8 +8,8 @@ namespace CShocker.Devices.APIs;
public class PiShockHttp : PiShockApi
{
// ReSharper disable twice MemberCanBePrivate.Global external usage
public string Username, Endpoint, ApiKey;
// ReSharper disable thrice MemberCanBePrivate.Global -> Exposed
public readonly string Username, Endpoint, ApiKey;
public PiShockHttp(string apiKey, string username, string endpoint = "https://do.pishock.com/api/apioperate", ILogger? logger = null) : base(DeviceApi.PiShockHttp, logger)
{

View File

@ -1,7 +1,6 @@
using System.IO.Ports;
using CShocker.Devices.Abstract;
using CShocker.Devices.Additional;
using CShocker.Ranges;
using CShocker.Shockers.Abstract;
using Microsoft.Extensions.Logging;
@ -10,7 +9,8 @@ namespace CShocker.Devices.APIs;
public class PiShockSerial : PiShockApi
{
private const int BaudRate = 115200;
public SerialPortInfo SerialPortI;
// ReSharper disable once MemberCanBePrivate.Global -> Exposed
public readonly SerialPortInfo SerialPortI;
private readonly SerialPort _serialPort;
public PiShockSerial(DeviceApi apiType, SerialPortInfo serialPortI, ILogger? logger = null) : base(apiType, logger)

View File

@ -7,7 +7,7 @@ namespace CShocker.Devices.Abstract;
public abstract class Api : IDisposable
{
// ReSharper disable 4 times MemberCanBePrivate.Global external use
// ReSharper disable 4 times MemberCanBePrivate.Global -> Exposed
protected ILogger? Logger;
public readonly DeviceApi ApiType;
private readonly Queue<ValueTuple<ControlAction, Shocker, int, int>> _queue = new();

View File

@ -8,10 +8,12 @@ namespace CShocker.Devices.Abstract;
public abstract class OpenShockApi : Api
{
// ReSharper disable twice MemberCanBeProtected.Global -> Exposed
public string Endpoint { get; init; }
public string ApiKey { get; init; }
private const string DefaultEndpoint = "https://api.shocklink.net";
// ReSharper disable once PublicConstructorInAbstractClass -> Exposed
public OpenShockApi(DeviceApi apiType, string apiKey, string endpoint = DefaultEndpoint, ILogger? logger = null) : base(apiType, new IntegerRange(0, 100), new IntegerRange(300, 30000), logger)
{
this.Endpoint = endpoint;
@ -33,12 +35,13 @@ public abstract class OpenShockApi : Api
return HashCode.Combine(Endpoint, ApiKey);
}
public List<OpenShockShocker> GetShockers()
public IEnumerable<OpenShockShocker> GetShockers()
{
return GetShockers(this.ApiKey, this, this.Endpoint, this.Logger);
}
public static List<OpenShockShocker> GetShockers(string apiKey, OpenShockApi api, string apiEndpoint = DefaultEndpoint, ILogger? logger = null)
// ReSharper disable once MemberCanBePrivate.Global
public static IEnumerable<OpenShockShocker> GetShockers(string apiKey, OpenShockApi api, string apiEndpoint = DefaultEndpoint, ILogger? logger = null)
{
List<OpenShockShocker> shockers = new();

View File

@ -1,7 +1,8 @@
namespace CShocker.Devices.Abstract;
public struct SerialPortInfo
public readonly struct SerialPortInfo
{
// ReSharper disable thrice MemberCanBePrivate.Global -> Exposed
public readonly string? PortName, Description, Manufacturer, DeviceID;
public SerialPortInfo(string? portName, string? description, string? manufacturer, string? deviceID)