Skip to content

Commit

Permalink
Merge pull request #124 from DevyusCode/vNext
Browse files Browse the repository at this point in the history
Version 1.7.0.2307
  • Loading branch information
lpeyr authored Jun 30, 2023
2 parents 6b8f442 + 4648835 commit 988e6be
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 22 deletions.
15 changes: 15 additions & 0 deletions PeyrSharp.Core/Maths/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,20 @@ public static double Variance(List<double> values)
int n = values.Count;
return variance / (n - 1);
}

/// <summary>
/// Calculates the standard deviation of a list of double numbers.
/// </summary>
/// <param name="values">The list of double numbers.</param>
/// <returns>The standard deviation of the list of double numbers.</returns>
/// <exception cref="ArgumentException">Thrown when the list is null or empty.</exception>
public static double StandardDeviation(List<double> values)
{
if (values == null || values.Count == 0)
{
throw new ArgumentException("The list cannot be null or empty.", nameof(values));
}
return Math.Sqrt(Variance(values));
}
}
}
13 changes: 8 additions & 5 deletions PeyrSharp.Core/PeyrSharp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.Core</Title>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<Authors>Devyus</Authors>
<Description>Core methods and features of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -16,8 +16,11 @@
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>- Fixed IsAvailableAsync() crashes when no internet connection is available
(#112)</PackageReleaseNotes>
<PackageReleaseNotes>- Added Range() method in Stats (#117)
- Added Variance() method in Stats (#118)
- Added StandardDeviation() method in Stats (#119)
- Improved exceptions
</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,8 +35,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Exceptions" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Enums" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Exceptions" Version="1.7.0.2307" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion PeyrSharp.Enums/PeyrSharp.Enums.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageProjectUrl>https://peyrsharp.leocorporation.dev/</PackageProjectUrl>
<RepositoryUrl>https://github.com/DevyusCode/PeyrSharp</RepositoryUrl>
<PackageTags>enums;c-sharp;dotnet;vb;peyrsharp;leo corp</PackageTags>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
Expand Down
7 changes: 4 additions & 3 deletions PeyrSharp.Env/PeyrSharp.Env.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.Env</Title>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<Authors>Devyus</Authors>
<Description>Environment-related methods of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -16,7 +16,8 @@
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageReleaseNotes>- Added UwpApp record (#120)
- Added the possibility to get UWP apps asynchronously (#120)</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -31,6 +32,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Enums" Version="1.7.0.2307" />
</ItemGroup>
</Project>
50 changes: 50 additions & 0 deletions PeyrSharp.Env/Sys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;

namespace PeyrSharp.Env
{
Expand Down Expand Up @@ -248,5 +251,52 @@ public static bool TerminateProcess(int processId)
return false;
}
}

/// <summary>
/// Retrieves a list of UWP (Universal Windows Platform) apps asynchronously.
/// </summary>
/// <remarks>Only works on Windows 10 and higher.</remarks>
/// <returns>A task that represents the asynchronous operation. The task result contains a list of UwpApp objects representing the UWP apps.</returns>
/// <exception cref="FileNotFoundException"></exception>
/// <exception cref="Win32Exception"></exception>
[SupportedOSPlatform("windows")]
public static async Task<List<UwpApp>> GetUwpAppsAsync()
{
ProcessStartInfo pInfo = new()
{
FileName = "powershell.exe",
Arguments = @"& Get-StartApps | ConvertTo-Json > $env:appdata\UwpApps.json",
UseShellExecute = true,
CreateNoWindow = true
};

Process process = new() { StartInfo = pInfo };
process.Start();
await process.WaitForExitAsync();

string appsFile = await File.ReadAllTextAsync($@"{FileSys.AppDataPath}\UWPapps.json");
List<UwpApp> apps = JsonSerializer.Deserialize<List<UwpApp>>(appsFile); // Get apps
List<UwpApp> sortedApps = new(); // Create final list
Dictionary<UwpApp, string> uwpApps = new(); // Create a dictionnary

// Sort apps to only have UWP apps (they have a "!" in the AppID property)
for (int i = 0; i < apps.Count; i++)
{
if (apps[i].AppID.Contains('!'))
{
uwpApps.Add(apps[i], apps[i].Name);
}
}

// Sort alphabetically
var sorted = from pair in uwpApps orderby pair.Value ascending select pair; // Sort

foreach (KeyValuePair<UwpApp, string> pair1 in sorted)
{
sortedApps.Add(pair1.Key);
}

return sortedApps; // Return
}
}
}
33 changes: 33 additions & 0 deletions PeyrSharp.Env/UwpApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
MIT License
Copyright (c) Devyus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

namespace PeyrSharp.Env
{
/// <summary>
/// Represents a smplified version of an UWP app object.
/// </summary>
/// <param name="Name">The name of the UWP app.</param>
/// <param name="AppID">The App ID in the Package Family Name property.</param>
public record UwpApp(string Name, string AppID);
}
2 changes: 1 addition & 1 deletion PeyrSharp.Exceptions/PeyrSharp.Exceptions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>PeyrSharp.Exceptions</Title>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<Company>Devyus</Company>
<Description>Exceptions of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand Down
4 changes: 2 additions & 2 deletions PeyrSharp.Extensions/PeyrSharp.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.Extensions</Title>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<Authors>Devyus</Authors>
<Description>Extensions methods of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Enums" Version="1.7.0.2307" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions PeyrSharp.UiHelpers/PeyrSharp.UiHelpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<UseWPF>true</UseWPF>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.UiHelpers</Title>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<Authors>Devyus</Authors>
<Description>Useful helpers for Windows Forms and Windows Presentation Framework.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -35,7 +35,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Enums" Version="1.7.0.2307" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion PeyrSharp/PeyrSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public static class PeyrSharp
/// <summary>
/// The current version of PeyrSharp.
/// </summary>
public static string Version => "1.6.1.2305";
public static string Version => "1.7.0.2307";
}
}
14 changes: 7 additions & 7 deletions PeyrSharp/PeyrSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net5.0;net6.0;net5.0-windows;net6.0-windows;net7.0;net7.0-windows</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp</Title>
<Version>1.6.1.2305</Version>
<Version>1.7.0.2307</Version>
<Authors>Devyus</Authors>
<Copyright>© 2023</Copyright>
<Description>A C# library designed to make developers' job easier.</Description>
Expand Down Expand Up @@ -32,12 +32,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Core" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Enums" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Env" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Exceptions" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Extensions" Version="1.6.1.2305" />
<PackageReference Condition="'$(TargetPlatformIdentifier)' == 'Windows'" Include="PeyrSharp.UiHelpers" Version="1.6.1.2305" />
<PackageReference Include="PeyrSharp.Core" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Enums" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Env" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Exceptions" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Extensions" Version="1.7.0.2307" />
<PackageReference Condition="'$(TargetPlatformIdentifier)' == 'Windows'" Include="PeyrSharp.UiHelpers" Version="1.7.0.2307" />
</ItemGroup>

</Project>

0 comments on commit 988e6be

Please sign in to comment.