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

Version 2.1.0.2312 #163

Merged
merged 11 commits into from
Dec 3, 2023
28 changes: 28 additions & 0 deletions PeyrSharp.Core/Converters/Temperatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,33 @@ public static class Temperatures
/// <param name="fahrenheit">Number of Fahrenheit to convert.</param>
/// <returns>The original value converted in Celsius.</returns>
public static double FahrenheitToCelsius(double fahrenheit) => (fahrenheit - 32) / 1.8; // Convert

/// <summary>
/// Converts a temperature value from Celsius to Kelvin.
/// </summary>
/// <param name="celsius">Temperature value in Celsius.</param>
/// <returns>Temperature value in Kelvin.</returns>
public static double CelsiusToKelvin(double celsius) => celsius + 273.15;

/// <summary>
/// Converts a temperature value from Fahrenheit to Kelvin.
/// </summary>
/// <param name="fahrenheit">Temperature value in Fahrenheit.</param>
/// <returns>Temperature value in Kelvin.</returns>
public static double FahrenheitToKelvin(double fahrenheit) => (fahrenheit + 459.67) * 5 / 9;

/// <summary>
/// Converts a temperature value from Kelvin to Celsius.
/// </summary>
/// <param name="kelvin">Temperature value in Kelvin.</param>
/// <returns>Temperature value in Celsius.</returns>
public static double KelvinToCelsius(double kelvin) => kelvin - 273.15;

/// <summary>
/// Converts a temperature value from Kelvin to Fahrenheit.
/// </summary>
/// <param name="kelvin">Temperature value in Kelvin.</param>
/// <returns>Temperature value in Fahrenheit.</returns>
public static double KelvinToFahrenheit(double kelvin) => kelvin * 9 / 5 - 459.67;
}
}
23 changes: 23 additions & 0 deletions PeyrSharp.Core/Internet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

using PeyrSharp.Enums;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

Expand Down Expand Up @@ -92,6 +93,28 @@
}
}

/// <summary>
/// Downloads a file from a specified link and saves it to a specified path.
/// </summary>
/// <param name="link">The URL of the file to download.</param>
/// <param name="path">The local path where the file should be saved.</param>
/// <returns>Returns true if the file was downloaded and saved successfully, otherwise returns false.</returns>
/// <exception cref="Exception">Throws an exception if an error occurs during the download or save process.</exception>
public static async Task<bool> DownloadFile(string link, string path)
{
try
{
using HttpClient client = new();
byte[] data = await client.GetByteArrayAsync(link);
await File.WriteAllBytesAsync(path, data);
return true;
}
catch
{
return false;
}
}

/// <summary>
/// Gets the kind of the status code.
/// </summary>
Expand Down Expand Up @@ -127,7 +150,7 @@
{
url = "https://" + url;
}
return Uri.TryCreate(url, UriKind.Absolute, out Uri? uriResult)

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 153 in PeyrSharp.Core/Internet.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest sample

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
}
}
Expand Down
34 changes: 34 additions & 0 deletions PeyrSharp.Core/Password.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,40 @@ public static Task<string> GenerateAsync(int length, string chars, string separa
return task;
}

/// <summary>
/// Asynchronously generates a string of a specified length using a given set of characters.
/// </summary>
/// <param name="length">The length of the string to generate.</param>
/// <param name="chars">An array of characters to use for generating the string.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the generated string.</returns>
/// <exception cref="Exception">Throws an exception if the length parameter is not greater than 0.</exception>
public static Task<string> GenerateAsync(int length, string[] chars)
{
Task<string> task = new(() =>
{
// Setup variables
string finalPassword = "";
Random random = new();
int number = 0;

if (length > 0) // Check if the length valid
{
for (int i = 1; i < length; i++) // Generate a password of a specific length
{
number = random.Next(0, chars.Length);
finalPassword += chars[number]; // Append a character to the string
}
}
else
{
throw new Exception("The parameter 'length' (int) must be higher than 0.");
}
return finalPassword;
});
task.Start();
return task;
}

/// <summary>
/// Generates a password asynchronously.
/// </summary>
Expand Down
15 changes: 10 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>net6.0;net7.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.Core</Title>
<Version>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<Authors>Devyus</Authors>
<Description>Core methods and features of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -16,8 +16,13 @@
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>- Added .NET 8 Support
- Removed .NET 5 Support</PackageReleaseNotes>
<PackageReleaseNotes>- Added DownloadFile() method (#157)
- Added XML Documentation
- Added new overload for GenerateAsync() in Password (#158)
- Added CelsiusToKelvin() method (#159)
- Added FahrenheitToKelvin() method (#159)
- Added KelvinToCelsius() method (#159)
- Added KelvinToFahrenheit() method (#159)</PackageReleaseNotes>
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="2.0.0.2311" />
<PackageReference Include="PeyrSharp.Exceptions" Version="2.0.0.2311" />
<PackageReference Include="PeyrSharp.Enums" Version="2.1.0.2312" />
<PackageReference Include="PeyrSharp.Exceptions" Version="2.1.0.2312" />
</ItemGroup>

</Project>
5 changes: 2 additions & 3 deletions PeyrSharp.Enums/PeyrSharp.Enums.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
<PackageProjectUrl>https://peyrsharp.leocorporation.dev/</PackageProjectUrl>
<RepositoryUrl>https://github.com/DevyusCode/PeyrSharp</RepositoryUrl>
<PackageTags>enums;c-sharp;dotnet;vb;peyrsharp;leo corp</PackageTags>
<Version>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>- Added .NET 8 Support
- Removed .NET 5 Support</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions PeyrSharp.Env/PeyrSharp.Env.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.Env</Title>
<Version>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<Authors>Devyus</Authors>
<Description>Environment-related methods of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -16,8 +16,7 @@
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>- Added .NET 8 Support
- Removed .NET 5 Support</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -33,6 +32,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="PeyrSharp.Enums" Version="2.0.0.2311" />
<PackageReference Include="PeyrSharp.Enums" Version="2.1.0.2312" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions 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>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<Company>Devyus</Company>
<Description>Exceptions of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -18,8 +18,7 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>- Added .NET 8 Support
- Removed .NET 5 Support</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions PeyrSharp.Extensions/PeyrSharp.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp.Extensions</Title>
<Version>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<Authors>Devyus</Authors>
<Description>Extensions methods of PeyrSharp.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -16,8 +16,7 @@
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>- Added .NET 8 Support
- Removed .NET 5 Support</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="2.0.0.2311" />
<PackageReference Include="PeyrSharp.Enums" Version="2.1.0.2312" />
</ItemGroup>

</Project>
7 changes: 3 additions & 4 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>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<Authors>Devyus</Authors>
<Description>Useful helpers for Windows Forms and Windows Presentation Framework.</Description>
<Copyright>© 2023</Copyright>
Expand All @@ -20,8 +20,7 @@
<PackageReadmeFile>NUGET_README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>- Added .NET 8 Support
- Removed .NET 5 Support</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -36,7 +35,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Enums" Version="2.0.0.2311" />
<PackageReference Include="PeyrSharp.Enums" Version="2.1.0.2312" />
</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 => "2.0.0.2311";
public static string Version => "2.1.0.2312";
}
}
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>net6.0;net6.0-windows;net7.0;net7.0-windows;net8.0;net8.0-windows</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Title>PeyrSharp</Title>
<Version>2.0.0.2311</Version>
<Version>2.1.0.2312</Version>
<Authors>Devyus</Authors>
<Copyright>© 2023</Copyright>
<Description>A C# library designed to make developers' job easier.</Description>
Expand Down Expand Up @@ -34,12 +34,12 @@
</ItemGroup>

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

</Project>
Loading