Added .NET Framework 4 target for "ComPortHelper" library
Update ComPortHelper.cs, ComPortInfo.cs, and 2 more files...
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Win32;
|
||||
using static NibblePoker.Library.RegistryHelpers.RegistryHelpers;
|
||||
|
||||
namespace NibblePoker.Library.ComPortWatcher;
|
||||
|
||||
namespace NibblePoker.Library.ComPortWatcher {
|
||||
public static class ComPortHelper {
|
||||
private const string RegistryKeySerial = "HARDWARE\\DEVICEMAP\\SERIALCOMM";
|
||||
private const string RegistryKeyDeviceEnum = "SYSTEM\\ControlSet001\\Enum";
|
||||
@@ -25,6 +26,7 @@ public static class ComPortHelper {
|
||||
RegistryKeyDeviceEnum + "\\" + subKey,
|
||||
true));
|
||||
}
|
||||
|
||||
subKeys.Clear();
|
||||
|
||||
foreach(string subSubKey in intermediateSubKeys) {
|
||||
@@ -33,15 +35,18 @@ public static class ComPortHelper {
|
||||
subSubKey,
|
||||
true));
|
||||
}
|
||||
|
||||
intermediateSubKeys.Clear();
|
||||
|
||||
foreach(string finalSubKey in finalSubKeys) {
|
||||
Dictionary<string, string> mappedKeyValues = GetMappedKeyNameStringValue(Registry.LocalMachine, finalSubKey);
|
||||
Dictionary<string, string> mappedKeyValues =
|
||||
GetMappedKeyNameStringValue(Registry.LocalMachine, finalSubKey);
|
||||
|
||||
if(mappedKeyValues.ContainsKey(RegistryNameFriendlyName)) {
|
||||
friendlyNames.Add(mappedKeyValues[RegistryNameFriendlyName]);
|
||||
}
|
||||
}
|
||||
|
||||
finalSubKeys.Clear();
|
||||
|
||||
foreach(ComPortInfo comPortInfo in comPortsInfo) {
|
||||
@@ -54,13 +59,15 @@ public static class ComPortHelper {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
friendlyNames.Clear();
|
||||
}
|
||||
|
||||
public static List<ComPortInfo> GetComList(bool addFriendlyNames = false) {
|
||||
List<ComPortInfo> portsInfo = new List<ComPortInfo>();
|
||||
|
||||
foreach(KeyValuePair<string, string> rawPortInfo in GetMappedKeyNameStringValue(Registry.LocalMachine, RegistryKeySerial)) {
|
||||
foreach(KeyValuePair<string, string> rawPortInfo in GetMappedKeyNameStringValue(Registry.LocalMachine,
|
||||
RegistryKeySerial)) {
|
||||
portsInfo.Add(new ComPortInfo(rawPortInfo.Value, rawPortInfo.Key));
|
||||
}
|
||||
|
||||
@@ -71,3 +78,4 @@ public static class ComPortHelper {
|
||||
return portsInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
namespace NibblePoker.Library.ComPortWatcher;
|
||||
|
||||
namespace NibblePoker.Library.ComPortWatcher {
|
||||
public class ComPortInfo {
|
||||
public string RawName;
|
||||
public string DeviceName;
|
||||
@@ -16,3 +15,4 @@ public class ComPortInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFrameworks>net40;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
|
||||
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
|
||||
<RootNamespace>NibblePoker.Library.ComPortWatcher</RootNamespace>
|
||||
<AssemblyName>NibblePoker.Library.ComPortHelpers</AssemblyName>
|
||||
<Configurations>Release</Configurations>
|
||||
@@ -11,7 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NibblePoker.Library.RegistryHelpers" Version="0.0.1" />
|
||||
<PackageReference Include="NibblePoker.Library.RegistryHelpers" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace NibblePoker.Library.ComPortWatcher;
|
||||
|
||||
namespace NibblePoker.Library.ComPortWatcher {
|
||||
public enum SortingOrder {
|
||||
Descending = -1,
|
||||
None = 0,
|
||||
Ascending = 1,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user