Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.6 #8

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions DataTypes/Email.cs

This file was deleted.

37 changes: 0 additions & 37 deletions DataTypes/SerialPort.cs

This file was deleted.

64 changes: 0 additions & 64 deletions Managers/Logger.cs

This file was deleted.

10 changes: 0 additions & 10 deletions RegExp.cs

This file was deleted.

16 changes: 2 additions & 14 deletions Utils.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using OrnaLibs.DataTypes;
using System.Text;

namespace OrnaLibs
namespace OrnaLibs
{
public static partial class Utils
{
#pragma warning disable CA1416
public static SerialPort[] GetSerialPorts() =>
public static (string Port, string Device)[] GetSerialPorts() =>
Environment.OSVersion.Platform switch
{
PlatformID.Win32NT => GetSerialPortsWindows(),
Expand All @@ -31,14 +28,5 @@ public static void CreateService(string id, string name, string path)
}
}
#pragma warning restore CA1416
public static string GetRandomString(int count)
{
var symbols = "qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM";
var text = new StringBuilder();
var rnd = new Random();
for(var i = 0; i < count; i++)
text.Append(symbols[rnd.Next(symbols.Length)]);
return text.ToString();
}
}
}
7 changes: 3 additions & 4 deletions Windows.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Win32;
using OrnaLibs.DataTypes;
using System.Diagnostics;
using System.Runtime.Versioning;
using System.Text;
Expand All @@ -26,14 +25,14 @@ public static void PowerShell(string script)
}

[SupportedOSPlatform("windows")]
private static SerialPort[] GetSerialPortsWindows()
private static (string, string)[] GetSerialPortsWindows()
{
using var registry = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DEVICEMAP\SERIALCOMM")!;
if (registry is null) return [];
var names = registry.GetValueNames();
var ports = new SerialPort[names.Length];
var ports = new (string, string)[names.Length];
for (var i = 0; i < names.Length; i++)
ports[i] = new SerialPort((string)registry.GetValue(names[i])!, names[i].Split('\\')[^1]);
ports[i] = ((string)registry.GetValue(names[i])!, names[i].Split('\\')[^1]);
return ports;
}
[SupportedOSPlatform("windows")]
Expand Down
Loading