CleanEngine.Shared.Extension 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CleanEngine.Shared.Extension --version 2.0.2
                    
NuGet\Install-Package CleanEngine.Shared.Extension -Version 2.0.2
                    
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="CleanEngine.Shared.Extension" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CleanEngine.Shared.Extension" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="CleanEngine.Shared.Extension" />
                    
Project file
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 CleanEngine.Shared.Extension --version 2.0.2
                    
#r "nuget: CleanEngine.Shared.Extension, 2.0.2"
                    
#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 CleanEngine.Shared.Extension@2.0.2
                    
#: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=CleanEngine.Shared.Extension&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=CleanEngine.Shared.Extension&version=2.0.2
                    
Install as a Cake Tool

CleanEngine.Shared.Extension

CleanEngine.Shared.Extension is an extension for commonly used functions and rapid development.

Extension for value types convert methods

int integerNum = "123".ToInt32();//123
double longNum = "123.456".ToDouble();//123.456
decimal roundDecimal = 123.456m.ToRound(2);//123.46
double roundDouble = 123.456d.ToRound(2);//123.46

Extension for json convert

var json = new { Id = 1, Name = "Levi" }.ToJson();//{"Id":1,"Name":"Levi"}
var obj = "{\"Id\":1,\"Name\":\"Levi\"}".ToObject<Student>();
string result = "{\"name\":\"levi\", \"age\":18}".JsonAppendNode("person", new Person(Address: "shenzhen", Count: 100));

Extension for datetime convert

string now = DateTime.Now.ToStandardString();//2024-03-27 16:32:10

Extension for string

bool isEmpty = "".IsEmpty();//true
bool isNotEmpty = "".IsNotEmpty();//false
bool isEqual = "abc".EqualsIgnoreCase("ABC");//true
bool isNumber = "123".IsNumber();//true
bool isInteger = "123.12".IsInteger();//false
bool isDateTime = "2024-03-27".IsDateTime();//true

Extension for IEnumerable

var list = new List<string>() { "abc", "efg", "ggg" };
foreach (var item in list.WithIndex<string>())
{
	var index = item.Index;//get index from collection
	var value = item.Item;
 }
var isEmpty = list.IsNullOrEmpty();//false
var isNotEmpty = list.IsNotNullOrEmpty();//true

File Helper

FilesHelper.AppendOrCreate("x:\\xxx\\xxx.txt", text);//if file not exists, create; And then write text
FilesHelper.AppendOrCreate("x:\\xxx\\xxx.txt", new List<string>() { "123", "456" }););//if file not exists, create; And then write text

Validator Helper

var isIntegerPositive = ValidatorHelper.IsIntegerPositive("-100");//false
var isEnglish = ValidatorHelper.IsEnglishCharacter("abc");//true
var isEnglishAndInteger = ValidatorHelper.IsIntegerAndEnglishCharacter("abc123");//true

HttpClient Helper

One statement for HttpGet/HttpPost (Below version v1.3.0)

//with header
var html = new HttpEngine().GetString("https://www.baidu.com", x=>x.WithHeader("Accept-Language", "zh-CN"));

//with headers
var html2 = new HttpEngine().GetString("https://www.baidu.com", x => x.WithHeaders(new
            {
                Host = "www.baidu.com",
                Connection= "keep-alive"
            }));

//response convert to Object
var obj = new HttpEngine().Post<Employee>("http://192.168.1.1", x=>x.WithBearerToken("token"));

//response convert to List
List<Employee> list = new HttpEngine().PostList<Employee>("http://192.168.1.1");

(Equal or above version v1.3.0)

var html = new HttpEngineBuilder().Build().PostString("https://www.baidu.com");

var result = new HttpEngineBuilder().AddRequestBody(x => x.WithObject(new
{
    password = "password",
    userCode = "user"
})).Build().PostString("http://192.168.1.1:8888/api/login");

var html = _httpEngineBuilder.AddRequestHeader(x => x.WithHeaders(new
{
    Host = "www.baidu.com",
    Connection = "keep-alive"
})).Build().GetString("https://www.baidu.com");

var result = new HttpEngineBuilder().AddRequestBody(x => x.WithObject(new
{
    password = "password",
    userCode = "user"
})).Build().PostString<TestResponse>("http://192.168.1.1:8888/api/login");

Snowflake Id Generator

long id = IdGenerator.DefaultInstance().NextId();//163697223064879104 Generate a snowflake id
long distributedId = new IdGenerator(1,1).NextId();//163697287460163584 Generate a distibuted snowflake id with distibuted configuration

Reflection Helper

var dept = new Department() { Id = 1, Name = "it" };
string beforValue = ReflectionHelper.SetProperty<Department>(dept, "Name", "hr");//set property by key, value
  • v1.3.2 (1)增强FileHelper功能
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.3.2 141 6/19/2025
3.3.0 267 3/6/2025
3.2.1 226 3/6/2025
3.1.0 143 12/1/2024
3.0.2 149 10/27/2024
3.0.1-beta 125 9/23/2024
3.0.0-beta 113 9/14/2024
2.1.0-beta 101 9/14/2024
2.0.2 156 8/23/2024
2.0.1 124 7/23/2024
2.0.0 135 7/13/2024
1.3.2 141 7/6/2024
1.3.1 141 6/30/2024
1.3.0 130 6/29/2024
1.2.5 135 5/27/2024
1.2.4 141 4/15/2024
1.2.1 142 3/28/2024
1.2.0 149 3/27/2024
1.1.9 140 3/27/2024
1.1.7 147 3/23/2024
1.1.6 139 3/23/2024
1.1.5 149 3/23/2024
1.1.4 155 3/6/2024
1.1.3 147 2/29/2024
1.1.2 147 2/27/2024
1.1.1 131 2/27/2024