Skip to content

common tools, methods, extension methods, etc... .net 常用工具类,公共方法,常用扩展方法等,基础类库

License

Notifications You must be signed in to change notification settings

WeihanLi/WeihanLi.Common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeihanLi.Common

WeihanLi.Common Latest Stable WeihanLi.Common Latest Preview Azure Pipelines Build Status GitHub Actions Build Status

Overview

WeihanLi.Common bundles a set of production-ready helpers, extensions, and middleware to simplify .NET application development. It covers dependency injection, AOP, eventing, logging, data access helpers, OTP utilities, templating, and more—built from real-world usage and battle-tested across services.

Packages

Package Description
WeihanLi.Common Core helpers and extensions: dependency resolver, configuration helpers, pipelines, TOTP utilities, command executors, etc.
WeihanLi.Common.Logging.Serilog Integration layer so core logging abstractions seamlessly forward to Serilog or Microsoft.Extensions.Logging.
WeihanLi.Extensions.Hosting Hosting helpers for quickly wiring background services, console apps, and DI bootstrapping.

Each package is available on NuGet and can be referenced independently.

Installation

Install the package you need using the .NET CLI or NuGet Package Manager:

dotnet add package WeihanLi.Common
# or install the Serilog integration
dotnet add package WeihanLi.Common.Logging.Serilog

Preview builds are also published; append --version <preview> to opt in.

Quick Start

using WeihanLi.Common.Helpers;

// Generate a TOTP code with the built-in helper.
var secret = $"{ApplicationHelper.ApplicationName}_demo_secret";
var code = TotpHelper.GenerateCode(secret);

Console.WriteLine($"Generated code: {code}");

var isValid = TotpHelper.ValidateCode(secret, code);
Console.WriteLine($"Valid code: {isValid}");

See samples/DotNetCoreSample and samples/AspNetCoreSample for richer scenarios that exercise DI decorators, event buses, logging pipelines, and more.

Feature Highlights

  • Dependency Injection: Lightweight container abstractions, decorator helpers, metadata-based registrations, proxy support, and integration with Microsoft.Extensions.DependencyInjection.
  • Fluent Aspects (AOP): Dynamic proxy-based interception with fluent configuration for method-level behaviors (logging, validation, caching, etc.).
  • Event Infrastructure: In-memory and queue-backed EventBus, EventStore, and handler helpers to wire publish/subscribe workflows.
  • Logging: Abstractions with adapters for built-in logging and Serilog plus formatting helpers to ship structured events.
  • Data Access Helpers: Dapper-style extensions over ADO.NET, entity mapping utilities, and SQL expression parsers to streamline data access layers.
  • OTP & Security: TOTP implementation, helpers, and service abstractions to secure user flows with minimal setup.
  • Templating & Text: Lightweight template engine and string utility helpers for dynamic content rendering.
  • Utilities: Process executor, pipeline builder, command helpers, configuration helpers, async invokers, and more.

Documentation & Samples

  • Browse the docs in docs/index.md and articles under docs/articles for deep dives.
  • API references can be generated with DocFX (docs/docfx.json).
  • Samples live under samples/ and demonstrate step-by-step usage patterns you can adapt.

Building & Testing

dotnet build
dotnet test

CI builds run with both Azure Pipelines (azure-pipelines.yml) and GitHub Actions (.github/workflows/default.yml), so you can rely on the same commands locally.

Release Notes

Head to the merged pull requests list or the docfx ReleaseNotes for a chronological view of changes.

About

common tools, methods, extension methods, etc... .net 常用工具类,公共方法,常用扩展方法等,基础类库

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages