TurgayAcar.WebLibrary
1.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TurgayAcar.WebLibrary --version 1.3.0
NuGet\Install-Package TurgayAcar.WebLibrary -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TurgayAcar.WebLibrary" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TurgayAcar.WebLibrary" Version="1.3.0" />
<PackageReference Include="TurgayAcar.WebLibrary" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TurgayAcar.WebLibrary --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TurgayAcar.WebLibrary, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TurgayAcar.WebLibrary@1.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TurgayAcar.WebLibrary&version=1.3.0
#tool nuget:?package=TurgayAcar.WebLibrary&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WebLibrary - .NET 9 Web Development Library
A comprehensive .NET 9 Class Library that provides generic methods, utilities, and operations for web development.
Features
🔧 Core Components
- Global Configuration: Centralized configuration management
- ServiceResult Model: Generic result wrapper for service operations
- HTTP Client Helper: Generic HTTP client operations
- Validation Helper: Data validation utilities
- Generic Extensions: Extension methods for common operations
- Generic Utilities: General-purpose utility methods
- Generic Service Base: Abstract base class for CRUD operations
🔐 Security & Authentication
- JWT Token Management: Token generation, validation, and claim extraction
- Password Security: BCrypt hashing, verification, and strength checking
- Encryption Utilities: AES encryption, SHA hashing, HMAC, and secure random generation
📊 Data Processing
- CSV Operations: Import/export with CsvHelper
- Excel Operations: Read/write Excel files with EPPlus
- Data Transformation: JSON/Dictionary conversion, object copying, and comparison
- Bulk Operations: Batch processing with parallel support
🗄️ Database Operations
- Generic Repository Pattern: CRUD operations with Dapper
- Query Builder: Dynamic SQL query construction
- Connection Management: Database connection factory pattern
- Unit of Work Pattern: Transaction management
- Database Helper: Utility operations for database management
Project Structure
WebLibrary/
├── Global.cs # Global constants and configuration
├── Models/
│ └── ServiceResult.cs # Generic result wrapper
├── Helpers/
│ ├── HttpClientHelper.cs # HTTP client operations
│ └── ValidationHelper.cs # Data validation
├── Extensions/
│ └── GenericExtensions.cs # Extension methods
├── Utilities/
│ └── GenericUtilities.cs # Utility methods
├── Services/
│ └── GenericServiceBase.cs # Base service class
├── Security/
│ ├── JwtTokenHelper.cs # JWT operations
│ ├── PasswordHelper.cs # Password security
│ └── EncryptionHelper.cs # Encryption utilities
├── DataProcessing/
│ ├── CsvDataHelper.cs # CSV operations
│ ├── ExcelHelper.cs # Excel operations
│ ├── DataTransformationHelper.cs # Data transformation
│ └── BulkOperationsHelper.cs # Bulk operations
└── Database/
├── IDbConnectionFactory.cs # Connection factory interface
├── SqlServerConnectionFactory.cs # SQL Server connection factory
├── QueryBuilder.cs # SQL query builder
├── IGenericRepository.cs # Repository interface
├── DapperGenericRepository.cs # Dapper repository implementation
├── IUnitOfWork.cs # Unit of work interface
├── UnitOfWork.cs # Unit of work implementation
└── DatabaseHelper.cs # Database utilities
WebLibraryTest/ # Test console application
└── Program.cs # Test implementation
Installation
NuGet Package
dotnet add package WebLibrary
Manual Installation
- Clone this repository
- Build the solution
- Reference the WebLibrary.dll in your project
Quick Start
Basic Usage
using WebLibrary.Models;
using WebLibrary.Helpers;
// Use ServiceResult for operation results
var result = ServiceResult<string>.Success("Operation completed");
// HTTP operations
var httpResult = await HttpClientHelper.GetAsync<MyModel>("https://api.example.com/data");
// Validation
bool isValidEmail = ValidationHelper.IsValidEmail("test@example.com");
Security Features
using WebLibrary.Security;
// JWT Token operations
var token = JwtTokenHelper.GenerateToken(claims, secretKey);
var isValid = JwtTokenHelper.ValidateToken(token, secretKey);
// Password hashing
var hashedPassword = PasswordHelper.HashPassword("mypassword");
var isValidPassword = PasswordHelper.VerifyPassword("mypassword", hashedPassword);
// Encryption
var encrypted = EncryptionHelper.AesEncrypt("sensitive data", key, iv);
var decrypted = EncryptionHelper.AesDecrypt(encrypted, key, iv);
Data Processing
using WebLibrary.DataProcessing;
// CSV operations
var csvResult = CsvDataHelper.WriteToCsv(data, "output.csv");
var readResult = CsvDataHelper.ReadFromCsv<MyModel>("input.csv");
// Excel operations
var excelResult = ExcelDataHelper.WriteToExcel(data, "output.xlsx");
var excelReadResult = ExcelDataHelper.ReadFromExcel<MyModel>("input.xlsx");
// Data transformation
var jsonResult = DataTransformationHelper.ToJson(myObject);
var dictResult = DataTransformationHelper.ToDictionary(myObject);
Database Operations
using WebLibrary.Database;
// Connection factory
var connectionFactory = new SqlServerConnectionFactory(connectionString);
// Repository pattern
public class UserRepository : DapperGenericRepository<User>
{
public UserRepository(IDbConnectionFactory connectionFactory)
: base(connectionFactory, "Users") { }
}
// Query builder
var query = new QueryBuilder()
.Select("Id", "Name", "Email")
.From("Users")
.Where("Age > @MinAge")
.OrderBy("Name")
.AddParameter("MinAge", 18)
.Build();
// Unit of Work
using var unitOfWork = new UnitOfWork(connectionFactory);
var userRepo = unitOfWork.GetRepository<User, UserRepository>();
await unitOfWork.CommitAsync();
Dependencies
- .NET 9.0
- BCrypt.Net-Next 4.0.3
- CsvHelper 33.1.0
- Dapper 2.1.66
- EPPlus 8.1.0
- Microsoft.Data.SqlClient 6.1.1
- System.IdentityModel.Tokens.Jwt 8.14.0
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License.
Updates
- v1.0.0: Initial release with core components
- v1.1.0: Added Security & Authentication features
- v1.2.0: Added Data Processing features
- v1.3.0: Added Database Operations with Dapper integration
Support
For issues and questions, please open an issue on GitHub.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- BCrypt.Net-Next (>= 4.0.3)
- CsvHelper (>= 33.1.0)
- Dapper (>= 2.1.66)
- EPPlus (>= 8.1.0)
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.Data.SqlClient (>= 6.1.1)
- Microsoft.Extensions.Configuration (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection (>= 9.0.8)
- Microsoft.Extensions.Logging (>= 9.0.8)
- System.IdentityModel.Tokens.Jwt (>= 8.14.0)
- System.Security.Cryptography.ProtectedData (>= 9.0.8)
- System.Text.Json (>= 9.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.