ShortCleanLinqExtensions 1.0.9

dotnet add package ShortCleanLinqExtensions --version 1.0.9
                    
NuGet\Install-Package ShortCleanLinqExtensions -Version 1.0.9
                    
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="ShortCleanLinqExtensions" Version="1.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ShortCleanLinqExtensions" Version="1.0.9" />
                    
Directory.Packages.props
<PackageReference Include="ShortCleanLinqExtensions" />
                    
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 ShortCleanLinqExtensions --version 1.0.9
                    
#r "nuget: ShortCleanLinqExtensions, 1.0.9"
                    
#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 ShortCleanLinqExtensions@1.0.9
                    
#: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=ShortCleanLinqExtensions&version=1.0.9
                    
Install as a Cake Addin
#tool nuget:?package=ShortCleanLinqExtensions&version=1.0.9
                    
Install as a Cake Tool

Short clean linq extensions

Sce is a .NET Nuget extensions to make things easier.

Nuget

Usage

using ShortCleanLinqExtensions.src.Extensions;

# Title
"ula leila".Title(); 
// Output: Ula Leila 

# Slug
"ula leila".Stug();
// Output: ula-leila


# Mask
"ula leila".Mask("*", 4);
// Output: ula *****

# Snake Case
"UlaLeila".Snake();
// Output: ula_leila

# Is Json
"[1,2,3]".IsJson();
// Output: true

# List To Json
var list = new List<string>() { "1", "2", "3" };
list.ToJson();
// Output: ["1","2","3"]

# List Collapse
var listC1 = new List<int>() { 4, 5, 6, 7 };
var listC2 = new List<int>() { 4, 5, 6, 7 };

var manyList = new List<List<int>>() { listC1, listC2 };
var listCollapsed = manyList
    .Collapse()
    .ToList();
Console.WriteLine("Collapse => " + listCollapsed.ToJson());
// Output: [4,5,6,7,4,5,6,7]


# Paginate API
var list = new List<string>() { "1", "2", "3" };
var listPagineted = list
.AsQueryable()
.Paginate(1, 10);
// Output: {"Page":1,"Limit":10,"FirstPage":null,"LastPage":null,"Total":3,"NextPage":null,"PreviousPage":null,"Data":["1","2","3"]}



# Paginate MVC or Razor Pages
   public class IndexModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;
        public readonly List<string> _dataSet;
        private readonly IHttpContextAccessor _httpContextAccessor;
        public PagedResponse<List<string>> Items { get; set; }
        public IndexModel(ILogger<IndexModel> logger, IHttpContextAccessor httpContextAccessor)
        {
            _logger = logger;
            _dataSet = new List<string>()
            {
                "joao",
                "joao1",
                "joao2",
                "joao3",
                "joao4",
                "joao5",
                "joao6",
                "joao7",
            };
            _httpContextAccessor = httpContextAccessor;
        }

        public void OnGet([FromQuery] int page = 1, [FromQuery] int limit = 2)
        {       
             Items = _dataSet
                .AsQueryable()
                .Paginate(page, limit, Request, _httpContextAccessor);
        }
    }

    ...Index.cshtml

       @Html.Raw(Model.Items.Links())

       //output:

<img src="./DOC/paginate-web.png" />


# When
bool condition = true;
var newListFiltered = listC1
    .AsQueryable()
    .When(condition, l => l.Equals(4))
    .ToList();
// Output: [4]

# WhenInclude
bool condition = true;
var newListFiltered = listC1
    .AsQueryable()
    .WhenInclude(condition, l => l.NavigationProperty.Property)
    .Select(l => l.NavigationProperty.Property)
    .ToArray();
// Output: [Property, Property]

params = Support.DateTime.Type.Machine || Support.DateTime.Type.UTC (default)
Now(params)

//Output: 01/21/2024 18:30:24

# Diff
List<int> firstList = new List<int>() { 1, 2, 3, 4, 5 };
List<int> secondList = new List<int>() { 2, 4, 6, 8 };
IEnumerable<int> diff = firstList.Diff(secondList);

// Output: String.Join(',', diff) => 1,3,5

# Automatic dependency injection scanner 

## You interfaces you need add extend the (IScopedService, ISingletonService or ISingletonService) 

Sample: 

    public interface ITest : IScopedService
    {
        decimal Calculate(int itemA, int itemB);
    } 
    
    ...
    
    public class Test : ITest
    {
        public decimal Calculate(int itemA, int itemB) => itemA + itemB;
    }



## You Have two option you can add with nuget or native
Settings: 

1 - builder.Services.AddDIScannerIOC(); // native
or 
2 - builder.Services.AddDIScannerIOCWithScrutor(); // with nuget scrutor

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Product 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. 
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
1.0.9 149 6/19/2024
1.0.8 136 6/9/2024
1.0.7 131 6/9/2024
1.0.6 148 1/21/2024
1.0.5 129 1/20/2024
1.0.4 241 10/23/2023
1.0.3 224 3/27/2023
1.0.2 218 3/27/2023
1.0.1 209 3/27/2023
1.0.0 206 3/27/2023