Skip to content

Commit

Permalink
imp - brk|doc - Use EnumMagic for enumerable extensions
Browse files Browse the repository at this point in the history
---

As EnumMagic has been made publicly available, we've started using this library.

---

Type: imp
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 1, 2024
1 parent cfcc406 commit 36e0bd9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using Terminaux.Inputs.Interactive;
using Terminaux.Inputs.Styles.Infobox;
using Nitrocid.Languages;
using Nitrocid.Misc.Reflection;
using EnumMagic;

namespace Nitrocid.Extras.UnitConv.Interactives
{
Expand Down Expand Up @@ -85,7 +85,7 @@ private static void OpenConvert()
var parser = UnitsNetSetup.Default.UnitParser;
var unitNames = GetUnitTypeNames();
var units = GetUnits();
string UnitType = (string)EnumerableTools.GetElementFromIndex(unitNames, InteractiveTuiStatus.FirstPaneCurrentSelection - 1);
string UnitType = (string)unitNames.GetElementFromIndex(InteractiveTuiStatus.FirstPaneCurrentSelection - 1);
int QuantityNum = Convert.ToInt32(answer);
string wholeUnit = units.OfType<string>().ElementAt(InteractiveTuiStatus.SecondPaneCurrentSelection - 1);
string SourceUnit = wholeUnit[..wholeUnit.IndexOf(' ')];
Expand Down
9 changes: 5 additions & 4 deletions public/Nitrocid/Kernel/Hardware/HardwareList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using EnumMagic;
using Nitrocid.Drivers.HardwareProber;
using Nitrocid.Kernel.Debugging;
using Nitrocid.Languages;
Expand Down Expand Up @@ -48,28 +49,28 @@ internal static void ListHardware()
var hardDrive = HardwareProbe.hardDrive;

// We are checking to see if any of the probers reported a failure starting with CPU
if (processors is null || processors is not null && EnumerableTools.CountElements(processors) == 0)
if (processors is null || processors is not null && processors.Length() == 0)
{
DebugWriter.WriteDebug(DebugLevel.E, "CPU failed to probe.");
SplashReport.ReportProgressError(Translate.DoTranslation("One or more of the CPU cores failed to probe. Showing information anyway..."));
}

// then RAM
if (pcMemory is null || pcMemory is not null && EnumerableTools.CountElements(pcMemory) == 0)
if (pcMemory is null || pcMemory is not null && pcMemory.Length() == 0)
{
DebugWriter.WriteDebug(DebugLevel.E, "RAM failed to probe.");
SplashReport.ReportProgressError(Translate.DoTranslation("One or more of the RAM chips failed to probe. Showing information anyway..."));
}

// then GPU
if (graphics is null || graphics is not null && EnumerableTools.CountElements(graphics) == 0)
if (graphics is null || graphics is not null && graphics.Length() == 0)
{
DebugWriter.WriteDebug(DebugLevel.E, "GPU failed to probe.");
SplashReport.ReportProgressError(Translate.DoTranslation("One or more of the graphics cards failed to probe. Showing information anyway..."));
}

// and finally HDD
if (hardDrive is null || hardDrive is not null && EnumerableTools.CountElements(hardDrive) == 0)
if (hardDrive is null || hardDrive is not null && hardDrive.Length() == 0)
{
DebugWriter.WriteDebug(DebugLevel.E, "HDD failed to probe.");
SplashReport.ReportProgressError(Translate.DoTranslation("One or more of the hard drives failed to probe. Showing information anyway..."));
Expand Down
75 changes: 0 additions & 75 deletions public/Nitrocid/Misc/Reflection/EnumerableTools.cs

This file was deleted.

3 changes: 2 additions & 1 deletion public/Nitrocid/Nitrocid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<NitrocidModAPIVersionMajor>3.0.25</NitrocidModAPIVersionMajor>

<!-- Increment NitrocidModAPIVersionChangeset every time there is a breaking change or an API addition in the N-KS API. -->
<NitrocidModAPIVersionChangeset>411</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>412</NitrocidModAPIVersionChangeset>

<!-- To be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down Expand Up @@ -103,6 +103,7 @@
<PackageReference Include="Terminaux.ResizeListener" Version="2.7.2" PrivateAssets="contentfiles;analyzers;build;runtime" />
<PackageReference Include="Textify.Offline" Version="1.3.1" PrivateAssets="contentfiles;analyzers;build;runtime" />
<PackageReference Include="Nettify" Version="1.1.0" PrivateAssets="contentfiles;analyzers;build;runtime" />
<PackageReference Include="EnumMagic" Version="0.1.0" PrivateAssets="contentfiles;analyzers;build;runtime" />
</ItemGroup>
<!-- KS Non-private Dependencies Information End -->

Expand Down

0 comments on commit 36e0bd9

Please sign in to comment.