DKNet.Fw.Extensions
9.0.31
dotnet add package DKNet.Fw.Extensions --version 9.0.31
NuGet\Install-Package DKNet.Fw.Extensions -Version 9.0.31
<PackageReference Include="DKNet.Fw.Extensions" Version="9.0.31" />
<PackageVersion Include="DKNet.Fw.Extensions" Version="9.0.31" />
<PackageReference Include="DKNet.Fw.Extensions" />
paket add DKNet.Fw.Extensions --version 9.0.31
#r "nuget: DKNet.Fw.Extensions, 9.0.31"
#:package DKNet.Fw.Extensions@9.0.31
#addin nuget:?package=DKNet.Fw.Extensions&version=9.0.31
#tool nuget:?package=DKNet.Fw.Extensions&version=9.0.31
DKNet.Fw.Extensions
A comprehensive collection of framework-level extensions and utilities for .NET applications. This package provides essential extension methods for common types, encryption utilities, and type manipulation tools to enhance productivity and code readability.
Features
- String Extensions: Number validation, digit extraction, and type checking utilities
- DateTime Extensions: Quarter calculations, month operations, and date manipulations
- Enum Extensions: Display attribute retrieval and enum information extraction
- Type Extensions: Generic type checking, value type validation, and reflection utilities
- Async Extensions: IAsyncEnumerable utilities for async data processing
- Property Extensions: Reflection-based property manipulation and type checking
- Attribute Extensions: Custom attribute retrieval and metadata operations
- Encryption Utilities: Built-in encryption and hashing capabilities
Supported Frameworks
- .NET 9.0+
Installation
Install via NuGet Package Manager:
dotnet add package DKNet.Fw.Extensions
Or via Package Manager Console:
Install-Package DKNet.Fw.Extensions
Quick Start
String Extensions
using DKNet.Fw.Extensions;
// Extract digits from mixed content
string text = "Price: $123.45";
string digits = text.ExtractDigits(); // "123.45"
// Check if string is a valid number
bool isValid = "123.45".IsNumber(); // true
DateTime Extensions
using DKNet.Fw.Extensions;
var date = DateTime.Now;
// Get last day of current month
DateTime lastDay = date.LastDayOfMonth();
// Get quarter information
int quarter = date.Quarter(); // 1, 2, 3, or 4
Enum Extensions
using DKNet.Fw.Extensions;
using System.ComponentModel.DataAnnotations;
public enum Status
{
[Display(Name = "Active Status")]
Active,
[Display(Name = "Inactive Status")]
Inactive
}
var status = Status.Active;
var displayAttr = status.GetAttribute<DisplayAttribute>();
string displayName = displayAttr?.Name ?? status.ToString();
Async Extensions
using System.Collections.Generic;
IAsyncEnumerable<int> asyncNumbers = GetAsyncNumbers();
IList<int> numbers = await asyncNumbers.ToListAsync();
Configuration
This package requires no specific configuration. Simply add the using statements for the namespaces you need:
using DKNet.Fw.Extensions; // Core extensions
using System.Collections.Generic; // Async extensions
API Reference
StringExtensions
ExtractDigits(string)
- Extracts numeric characters from a stringIsNumber(string)
- Validates if a string represents a valid numberIsStringOrValueType(PropertyInfo)
- Checks if property can store string or value types
DateTimeExtensions
LastDayOfMonth(DateTime)
- Returns the last day of the monthQuarter(DateTime)
- Determines the quarter of the year (1-4)
EnumExtensions
GetAttribute<T>(Enum)
- Retrieves custom attributes from enum valuesGetEnumInfo(Enum)
- Gets comprehensive enum information including display attributes
TypeExtensions
IsStringOrValueType(Type)
- Determines if type is string or value type- Various generic type checking utilities
AsyncEnumerableExtensions
ToListAsync<T>(IAsyncEnumerable<T>)
- Converts async enumerable to list
Advanced Usage
Type Checking with Reflection
using DKNet.Fw.Extensions;
using System.Reflection;
public class Example
{
public string Name { get; set; }
public int Age { get; set; }
public DateTime? BirthDate { get; set; }
}
// Check if properties can store simple values
var properties = typeof(Example).GetProperties();
foreach (var prop in properties)
{
bool canStoreSimpleValue = prop.IsStringOrValueType();
Console.WriteLine($"{prop.Name}: {canStoreSimpleValue}");
}
Working with Display Attributes
using DKNet.Fw.Extensions;
using System.ComponentModel.DataAnnotations;
public enum Priority
{
[Display(Name = "Low Priority", Description = "Non-urgent items")]
Low,
[Display(Name = "High Priority", Description = "Urgent items")]
High
}
// Get detailed enum information
var priority = Priority.High;
var enumInfo = priority.GetEnumInfo();
// Access enumInfo.DisplayName, enumInfo.Description, etc.
Thread Safety
- All extension methods are thread-safe as they are stateless
- Encryption utilities maintain thread safety
- No shared mutable state across method calls
Performance Considerations
- String operations use modern .NET patterns and are optimized for performance
- Reflection-based operations are cached where possible
- Async operations follow .NET async best practices
Contributing
See the main CONTRIBUTING.md for guidelines on how to contribute to this project.
License
This project is licensed under the MIT License.
Related Packages
- DKNet.EfCore.Extensions - Entity Framework Core specific extensions
- DKNet.SlimBus.Extensions - Messaging extensions for SlimMessageBus
Part of the DKNet Framework - A comprehensive .NET framework for building modern, scalable applications.
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. |
-
net9.0
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.9)
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DKNet.Fw.Extensions:
Package | Downloads |
---|---|
DKNet.EfCore.Extensions
Package Description |
|
DKNet.EfCore.Hooks
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
9.0.31 | 55 | 9/19/2025 |
9.0.30 | 74 | 9/18/2025 |
9.0.29 | 69 | 9/18/2025 |
9.0.28 | 87 | 9/17/2025 |
9.0.27 | 81 | 9/17/2025 |
9.0.26 | 95 | 9/16/2025 |
9.0.25 | 103 | 9/15/2025 |
9.0.24 | 105 | 9/15/2025 |
9.0.23 | 125 | 9/6/2025 |
9.0.22 | 172 | 9/3/2025 |
9.0.21 | 145 | 9/1/2025 |
9.0.20 | 167 | 7/15/2025 |
9.0.19 | 164 | 7/14/2025 |
9.0.18 | 167 | 7/14/2025 |
9.0.17 | 162 | 7/14/2025 |
9.0.16 | 142 | 7/11/2025 |
9.0.15 | 152 | 7/11/2025 |
9.0.14 | 145 | 7/11/2025 |
9.0.13 | 154 | 7/11/2025 |
9.0.12 | 167 | 7/8/2025 |
9.0.11 | 165 | 7/8/2025 |
9.0.10 | 171 | 7/7/2025 |
9.0.9 | 170 | 7/2/2025 |
9.0.8 | 163 | 7/2/2025 |
9.0.7 | 164 | 7/1/2025 |
9.0.6 | 164 | 6/30/2025 |
9.0.5 | 165 | 6/24/2025 |
9.0.4 | 167 | 6/24/2025 |
9.0.3 | 168 | 6/23/2025 |
9.0.2 | 171 | 6/23/2025 |
9.0.1 | 169 | 6/23/2025 |