Ozcorps.Core
9.1.0
dotnet add package Ozcorps.Core --version 9.1.0
NuGet\Install-Package Ozcorps.Core -Version 9.1.0
<PackageReference Include="Ozcorps.Core" Version="9.1.0" />
<PackageVersion Include="Ozcorps.Core" Version="9.1.0" />
<PackageReference Include="Ozcorps.Core" />
paket add Ozcorps.Core --version 9.1.0
#r "nuget: Ozcorps.Core, 9.1.0"
#:package Ozcorps.Core@9.1.0
#addin nuget:?package=Ozcorps.Core&version=9.1.0
#tool nuget:?package=Ozcorps.Core&version=9.1.0
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.0net9.0net10.0
Installation
dotnet add package Ozcorps.Core --version 9.0.0
What's Included
Ozcorps.Core.Models.Response<T>andResponse- 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 implementations→ moved 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:
DataSuccessMessageErrorsTraceIdTimestamp
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
Nest7.x client.
License
MIT
| Product | Versions 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. |
-
net8.0
- FluentValidation (>= 12.1.1)
- Microsoft.Extensions.Configuration.Binder (>= 7.0.4)
- Microsoft.Extensions.Options (>= 7.0.1)
- Nest (>= 7.17.5)
- NetTopologySuite (>= 2.5.0)
- Ozcorps.DynamicLinq (>= 1.2.1)
- ProjNet (>= 2.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Ozcorps.Core:
| Package | Downloads |
|---|---|
|
Ozcorps.Logger
Package Description |
|
|
Ozcorps.Ozt
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.