Ozcorps.Core 9.1.0

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

Ozcorps.Core

Ozcorps.Core is a multi-targeted utility package for ASP.NET Core applications. It provides reusable building blocks for response modeling, dynamic query operations, encryption helpers, geometry conversion utilities, and Elasticsearch integration.

Target Frameworks

  • net8.0
  • net9.0
  • net10.0

Installation

dotnet add package Ozcorps.Core --version 9.0.0

What's Included

  • Ozcorps.Core.Models.Response<T> and Response
  • Dynamic query helpers in Ozcorps.Core.Extensions.QueryExtensions
  • Geometry conversion and projection helpers in Ozcorps.Core.Extensions.GeometryExtensions
  • Elasticsearch provider and generic service (IElasticSearchProvider, IElasticSearchService<T>)
  • Security headers middleware (HeadersMiddleware, HeaderOption)
  • Encryption abstractions and implementationsmoved to Ozcorps.Security

Response Model

Use a consistent API response contract:

using Ozcorps.Core.Models;

var success = Response<string>.Ok("done", "Operation completed");
var failed = Response<string>.Fail("Validation failed", new Dictionary<string, string[]>
{
    ["Email"] = new[] { "Email is required" }
});

Response<T> includes:

  • Data
  • Success
  • Message
  • Errors
  • TraceId
  • Timestamp

Encryption Services

Deprecated. All encryption types (IEncryptor, IFileEncryptor, RsaEncryptor, Md5Encryptor, FileEncryptor) have been moved to the Ozcorps.Security package and are marked [Obsolete] here. They will be removed in the next major version.

dotnet add package Ozcorps.Security

Elasticsearch Integration

Register provider and generic service:

using Microsoft.Extensions.DependencyInjection;

builder.Services.AddElasticSearchProvider();

Configuration:

{
  "ElasticSearch": {
    "Host": "http://localhost:9200"
  }
}

Usage:

public class ProductSearchService
{
    private readonly IElasticSearchService<Product> _service;

    public ProductSearchService(IElasticSearchService<Product> service)
    {
        _service = service;
    }

    public IQueryable<Product> Search(string index)
    {
        return _service.Search(index, page: 0, rowCount: 20);
    }
}

Query Extensions

QueryExtensions supports runtime filtering, searching, ordering, and pagination over IQueryable.

Example:

var filtered = query.SearchAnd(
    new[] { "Name", "Status" },
    new[] { "john", "active" },
    new[] { "contains", "==" });

var ordered = filtered.OrderHelper(
    new[] { "asc" },
    new[] { "Name" });

Geometry Extensions

The geometry helpers are based on NetTopologySuite and ProjNet.

Capabilities include:

  • WKT/WKB conversions
  • Simplification
  • SRID transformations (WGS84, WebMercator, TM, UTM variants)

Example:

using Ozcorps.Core.Extensions;

var geometry = "POINT(29.0 41.0)".WktToGeometry();
var mercator = geometry.ToWebMerkator();
var wkt = mercator.ToWkt();

Middlewares

ExceptionHandlingMiddleware

Catches unhandled exceptions globally and returns structured JSON error responses.

Exception Status Code
ValidationException 400 Bad Request — includes field-level errors
UnauthorizedAccessException 401 Unauthorized
InvalidOperationException 409 Conflict
Any other Exception 500 Internal Server Error — includes traceId

Register in your pipeline:

app.UseExceptionHandling();

HeadersMiddleware

Adds or removes security-related HTTP response headers via HeaderOption.

var headerOption = new HeaderOption
{
    ReferrerPolicy = "no-referrer",
    XContentTypeOptions = "nosniff",
    XFrameOptions = "DENY",
    XXssProtection = "1; mode=block",
    XPermittedCrossDomainPolicies = "none",
    ContentSecurityPolicies = new List<string> { "default-src 'self'" },
    FeaturePolicies = new List<string> { "camera 'none'" },
    HeadersToRemove = new List<string> { "Server", "X-Powered-By" }
};

app.UseMiddleware<HeadersMiddleware>(headerOption);

Notes

  • Package metadata includes PackageReadmeFile, and this file is packed into the NuGet package.
  • XML documentation file generation is enabled.
  • Elasticsearch integration uses the Nest 7.x client.

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 (3)

Showing the top 3 NuGet packages that depend on Ozcorps.Core:

Package Downloads
Ozcorps.Logger

Modular, extensible logging library for ASP.NET Core. Routes logs to text files, RabbitMQ, Logstash (ELK), or OTLP-compatible backends (Grafana, Aspire Dashboard) through a single IOzLogger interface.

Ozcorps.Ozt

A lightweight token-based authentication and authorization library for ASP.NET Core. Features encrypted compressed tokens, role and permission based authorization, optional Redis permission store, gRPC session validation, and Swagger integration.

Ozcorps.Generic

Generic repository, unit-of-work, service, and CRUD controller base classes for ASP.NET Core with Entity Framework Core. Supports spatial queries, Snowflake IDs, soft-delete, audit fields, and versioning.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.0 239 3/11/2026
9.0.0 127 2/26/2026
8.4.0 1,513 9/17/2025
8.3.6 1,615 8/5/2025
8.3.5 3,185 7/11/2025
8.3.4 239 7/11/2025
8.3.3 219 7/11/2025
8.3.2 233 7/9/2025
8.3.0 264 4/9/2025
Loading failed