MyClassLibrary027.Utilities
1.0.11
dotnet add package MyClassLibrary027.Utilities --version 1.0.11
NuGet\Install-Package MyClassLibrary027.Utilities -Version 1.0.11
<PackageReference Include="MyClassLibrary027.Utilities" Version="1.0.11" />
<PackageVersion Include="MyClassLibrary027.Utilities" Version="1.0.11" />
<PackageReference Include="MyClassLibrary027.Utilities" />
paket add MyClassLibrary027.Utilities --version 1.0.11
#r "nuget: MyClassLibrary027.Utilities, 1.0.11"
#:package MyClassLibrary027.Utilities@1.0.11
#addin nuget:?package=MyClassLibrary027.Utilities&version=1.0.11
#tool nuget:?package=MyClassLibrary027.Utilities&version=1.0.11
MyClassLibrary027.Utilities
Utility functions for common tasks like prime checking and file splitting, plus a custom Swagger attribute to enhance API documentation by adding descriptive info to Swagger UI summaries and descriptions.
Installation
You can install the package from NuGet.org:
dotnet add package MyClassLibrary027.Utilities
Or, if you're using Visual Studio, you can search for the package in the NuGet Package Manager and install it from there.
Functions
CheckPrime(int prime)
Checks if a number is prime.
Utilities.CheckPrime(5); // Output: Prime Number
Utilities.CheckPrime(10); // Output: Not Prime Number
SplitFile(string filePath, int n = 10000)
Splits a large file into smaller chunks, each with a maximum size of n
characters. The default value of n
is 10,000 characters.
filePath
(string): The path to the file to be split.n
(int, optional): The maximum size of each chunk (default is 10,000 characters).
Utilities.SplitFile("path/to/largefile.txt", 5000);
This will split the file into chunks of 5,000 characters each and save them as separate files in the same directory.
SwaggerInfoAttribute
Use SwaggerInfoAttribute
on API methods to add custom info in Swagger UI. Register the filter:
services.AddSwaggerGen(c =>
{
// Other Swagger configuration...
c.OperationFilter<SwaggerInfoOperationFilter>();
});
Example:
[ApiController]
[Route("api/[controller]")]
public class SampleController : ControllerBase
{
[HttpGet("data")]
[SwaggerInfo("Requires Admin", Description = "Requires admin privileges.")]
public IActionResult GetSensitiveData() => Ok(new { Message = "Secret data" });
[HttpGet("public")]
[SwaggerInfo("Public Access")]
public IActionResult GetPublicData() => Ok(new { Message = "Public data" });
[HttpGet("status")]
[SwaggerInfo()]
public IActionResult GetStatus() => Ok(new { Message = "All systems operational" });
}
What happens:
For the
GetSensitiveData
endpoint, Swagger UI summary will start with[Requires Admin]
and the description panel will include your info text:🔹 Info: This endpoint requires admin privileges and returns sensitive data.
For the
GetPublicData
endpoint, summary will start with[Public Access]
and description stays unchanged (since Description was not provided).For the
GetStatus
endpoint, the summary will display[Additional endpoint info]
(the default), and the description will remain unchanged because no Description was provided.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Swashbuckle.AspNetCore.SwaggerGen (>= 8.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.11 | 210 | 6/2/2025 |