diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..586c5fb7
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,270 @@
+root = true
+
+[*]
+roslynator_accessibility_modifiers = explicit
+roslynator_use_anonymous_function_or_method_group = anonymous_function|method_group
+roslynator_enum_has_flag_style = method
+roslynator_object_creation_type_style = explicit|implicit|implicit_when_type_is_obvious
+
+indent_style = space
+
+trim_trailing_whitespace = true
+
+insert_final_newline = false
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.json]
+indent_size = 2
+
+[*.cs]
+dotnet_sort_system_directives_first = true:warning
+
+csharp_style_namespace_declarations = file_scoped:warning
+
+csharp_style_var_for_built_in_types = false:warning
+
+csharp_style_var_when_type_is_apparent = true:warning
+
+csharp_style_var_elsewhere = true:warning
+
+csharp_new_line_before_members_in_anonymous_types = true:warning
+
+# SA1623: Property summary documentation should match accessors
+dotnet_diagnostic.SA1623.severity = none
+
+# SA1101: Prefix local calls with this
+dotnet_diagnostic.SA1101.severity = none
+
+# SA1642: Constructor summary documentation should begin with standard text
+dotnet_diagnostic.SA1642.severity = none
+
+# SA1309: Field names should not begin with underscore
+dotnet_diagnostic.SA1309.severity = none
+
+# RCS1194: Implement exception constructors.
+dotnet_diagnostic.RCS1194.severity = none
+
+# SA1000: Keywords should be spaced correctly
+dotnet_diagnostic.SA1000.severity = none
+
+# SA1124: Do not use regions
+dotnet_diagnostic.SA1124.severity = none
+
+# SA1413: Use trailing comma in multi-line initializers
+dotnet_diagnostic.SA1413.severity = none
+
+# SA1201: Elements should appear in the correct order
+dotnet_diagnostic.SA1201.severity = suggestion
+
+# SA1638: File header file name documentation should match file name
+dotnet_diagnostic.SA1638.severity = warning
+
+# SA1633: File should have header
+dotnet_diagnostic.SA1633.severity = none
+
+# SA1404: Code analysis suppression should have justification
+dotnet_diagnostic.SA1404.severity = none
+
+# SA1206: Declaration keywords should follow order
+dotnet_diagnostic.SA1206.severity = none
+
+# CA1040: Avoid empty interfaces
+dotnet_diagnostic.CA1040.severity = none
+
+# RCS1012: Use explicit type instead of 'var'
+dotnet_diagnostic.RCS1012.severity = none
+
+# RCS1008: Use explicit type instead of 'var'
+dotnet_diagnostic.RCS1008.severity = none
+
+# CA1725
+dotnet_diagnostic.CA1725.severity = none
+
+# RCS1009: Use explicit type instead of 'var'
+dotnet_diagnostic.RCS1009.severity = none
+
+# SA1402: File may only contain a single type
+dotnet_diagnostic.SA1402.severity = suggestion
+
+# CA1711
+dotnet_diagnostic.CA1711.severity = none
+
+# CA1720: Identifier contains type name
+dotnet_diagnostic.CA1720.severity = none
+
+# IDE0022: Use block body for methods
+dotnet_diagnostic.IDE0022.severity = none
+
+# SA1011: Closing square brackets should be spaced correctly
+dotnet_diagnostic.SA1011.severity = none
+
+# CA1721
+dotnet_diagnostic.CA1721.severity = none
+
+# SA1313: Parameter names should begin with lower-case letter
+dotnet_diagnostic.SA1313.severity = none
+
+# SecurityIntelliSenseCS: MS Security rules violation
+dotnet_diagnostic.SecurityIntelliSenseCS.severity = suggestion
+
+# SA1123: Do not place regions within elements
+dotnet_diagnostic.SA1123.severity = none
+
+# RCS1046: Add suffix 'Async' to asynchronous method name
+dotnet_diagnostic.RCS1046.severity = warning
+
+# SA1625: Element documentation should not be copied and pasted
+dotnet_diagnostic.SA1625.severity = none
+
+# SCS9999
+dotnet_diagnostic.SCS9999.severity = none
+
+# RCS1090 Add call to 'ConfigureAwait'
+dotnet_diagnostic.RCS1090.severity = none
+
+# RCS1170 Use read-only auto-implemented property
+dotnet_diagnostic.RCS1170.severity = none
+
+# SA1649
+dotnet_diagnostic.SA1649.severity = none
+
+# RCS1021 Use expression-bodied lambda.
+dotnet_diagnostic.RCS1021.severity = none
+
+# RCS1047 Remove suffix 'Async' from non-asynchronous method name.
+# dotnet_diagnostic.RCS1047.severity = silent
+
+# SA1600 Elements should be documented
+dotnet_diagnostic.SA1600.severity = silent
+
+# CS1591 Missing XML comment for publicly visible type or member
+dotnet_diagnostic.CS1591.severity = none
+
+# SA1602: Enumeration items should be documented
+dotnet_diagnostic.SA1602.severity = none
+
+# CA1720 Identifier 'Decimal' contains type name
+dotnet_diagnostic.CA1720.severity = none
+
+# SA1601: Partial elements should be documented
+dotnet_diagnostic.SA1601.severity = silent
+
+# CA1711 Rename type name UserEventHandler so that it does not end in 'EventHandler'
+dotnet_diagnostic.CA1711.severity = none
+
+# CA1307: Specify StringComparison for clarity
+dotnet_diagnostic.CA1307.severity = none
+csharp_using_directive_placement = outside_namespace:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_prefer_braces = true:silent
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_accessors = true:silent
+csharp_style_expression_bodied_lambdas = true:silent
+csharp_style_expression_bodied_local_functions = false:silent
+csharp_indent_labels = one_less_than_current
+csharp_style_prefer_primary_constructors = true:suggestion
+csharp_style_prefer_null_check_over_type_check = true:suggestion
+csharp_style_throw_expression = true:suggestion
+csharp_style_prefer_local_over_anonymous_function = true:suggestion
+csharp_prefer_simple_default_expression = true:suggestion
+csharp_style_prefer_index_operator = true:suggestion
+csharp_style_prefer_range_operator = true:suggestion
+csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
+csharp_style_prefer_tuple_swap = true:suggestion
+csharp_style_inlined_variable_declaration = true:suggestion
+csharp_style_prefer_utf8_string_literals = true:suggestion
+csharp_style_unused_value_assignment_preference = discard_variable:suggestion
+csharp_style_deconstructed_variable_declaration = true:suggestion
+csharp_style_unused_value_expression_statement_preference = discard_variable:silent
+csharp_style_prefer_readonly_struct = true:suggestion
+csharp_prefer_static_local_function = true:suggestion
+csharp_style_prefer_readonly_struct_member = true:suggestion
+csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
+csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
+csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
+csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
+csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
+csharp_style_conditional_delegate_call = true:suggestion
+csharp_space_around_binary_operators = before_and_after
+[*.{cs,vb}]
+#### Naming styles ####
+
+# Naming rules
+
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+
+dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+
+# Symbol specifications
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.required_modifiers =
+
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.required_modifiers =
+
+# Naming styles
+
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
+dotnet_style_prefer_auto_properties = true:silent
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+tab_width = 4
+indent_size = 4
+end_of_line = crlf
+dotnet_style_prefer_collection_expression = true:suggestion
+dotnet_style_explicit_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_compound_assignment = true:suggestion
+dotnet_style_prefer_simplified_interpolation = true:suggestion
+dotnet_style_namespace_match_folder = true:suggestion
+dotnet_style_readonly_field = true:suggestion
+dotnet_style_predefined_type_for_member_access = true:silent
+dotnet_style_predefined_type_for_locals_parameters_members = true:silent
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
+dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
+dotnet_style_allow_multiple_blank_lines_experimental = true:silent
+dotnet_code_quality_unused_parameters = all:suggestion
diff --git a/templates/template/.env b/.env
similarity index 93%
rename from templates/template/.env
rename to .env
index a76ec7d7..d6d68734 100644
--- a/templates/template/.env
+++ b/.env
@@ -5,3 +5,6 @@
# The IP below should be swapped to your real IP or DNS name, like 192.168.88.248, etc. if testing from remote browsers or mobile devices
PROJECT_EXTERNAL_DNS_NAME_OR_IP=localhost
+
+# The docker image version
+DOCKER_IMAGE_TAG=6.0.0
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 00000000..7ab2dabb
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,3 @@
+# These are supported funding model platforms
+open_collective: genocs
+custom: ["https://www.buymeacoffee.com/genocs"]
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..c982b5fe
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,11 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+updates:
+ - package-ecosystem: "nuget" # See documentation for possible values
+ directory: "/" # Location of package manifests
+ schedule:
+ interval: "weekly" # How often to check for updates (can be "daily", "weekly" or "monthly")
diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml
index ce398d56..f18640fa 100644
--- a/.github/workflows/build_and_test.yml
+++ b/.github/workflows/build_and_test.yml
@@ -2,10 +2,9 @@ name: Build test and pack
on:
push:
- branches: ["master"]
-
+ branches: [main, develop]
pull_request:
- branches: ["master"]
+ branches: [main, develop]
jobs:
build:
@@ -14,21 +13,21 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup .NET
- uses: actions/setup-dotnet@v2
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: 7.0.x
+ dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
- run: dotnet build --no-restore
+ run: dotnet build -c Debug --no-restore
- name: Test
- run: dotnet test --no-build --verbosity normal
+ run: dotnet test -c Debug --no-build --verbosity normal
- name: Pack
- run: dotnet pack --no-build --verbosity normal
+ run: dotnet pack -c Debug --no-build --verbosity normal
diff --git a/.github/workflows/dockerhub-publish.yml b/.github/workflows/dockerhub-publish.yml
new file mode 100644
index 00000000..e8d987f2
--- /dev/null
+++ b/.github/workflows/dockerhub-publish.yml
@@ -0,0 +1,57 @@
+# This is a manually triggered dockerhub build and publish
+
+name: Publish to Dockerhub
+
+# Controls when the action will run. Workflow runs when manually triggered using the UI
+# or API.
+on:
+ workflow_dispatch:
+ # Inputs the workflow accepts.
+ inputs:
+ version:
+ # Friendly description to be shown in the UI instead of 'name'
+ description: "Image Version"
+
+ # Default value if no value is explicitly provided
+ default: "6.2.0"
+
+ # Input has to be provided for the workflow to run
+ required: true
+
+jobs:
+ build:
+ name: Publish Docker Image
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 8.0.x
+
+ - name: Restore dependencies
+ run: dotnet restore
+
+ - name: Build
+ run: dotnet build -c Debug --no-restore
+
+ - name: Test
+ run: dotnet test --no-build --verbosity normal
+
+ - name: Pack
+ run: dotnet pack --no-build --verbosity normal
+
+ - name: Docker Hub Log in
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+
+ - name: Build and push image to Dockerhub
+ run: |
+ docker build -f webapi.dockerfile -t genocs/demo-webapi:${{ github.event.inputs.version }} -t genocs/demo-webapi:latest .
+ docker push genocs/demo-webapi:${{ github.event.inputs.version }}
+ docker push genocs/demo-webapi:latest
diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml
index 89c68139..7e70f358 100644
--- a/.github/workflows/nuget-publish.yml
+++ b/.github/workflows/nuget-publish.yml
@@ -13,24 +13,24 @@ on:
description: "Packages Version"
# Default value if no value is explicitly provided
- default: "5.0.0-preview.4.0"
+ default: "6.2.0"
# Input has to be provided for the workflow to run
required: true
-
jobs:
build:
name: Update NuGet packages
runs-on: ubuntu-latest
+
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup .NET
- uses: actions/setup-dotnet@v2
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: 7.0.x
+ dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
@@ -42,7 +42,7 @@ jobs:
run: dotnet test --no-build --verbosity normal
- name: Pack
- run: dotnet pack -c Debug -o out -p:Version=${{ github.event.inputs.version }} --no-build --verbosity normal
+ run: dotnet pack -c Debug -o out -p:PackageVersion=${{ github.event.inputs.version }} --no-build --verbosity normal
- name: Push packages to Nuget
- run: dotnet nuget push ./out/*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
+ run: dotnet nuget push ./out/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
diff --git a/.gitignore b/.gitignore
index c1aafb51..65f178a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
+*.rsuser
*.suo
*.user
*.userosscache
@@ -12,6 +13,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
+# Mono auto generated files
+mono_crash.*
+
# Build results
[Dd]ebug/
[Dd]ebugPublic/
@@ -19,10 +23,14 @@
[Rr]eleases/
x64/
x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
+[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
@@ -36,9 +44,10 @@ Generated\ Files/
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
-# NUNIT
+# NUnit
*.VisualState.xml
TestResult.xml
+nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
@@ -54,6 +63,12 @@ project.fragment.lock.json
artifacts/
# **/Properties/launchSettings.json
+# Tye
+.tye/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
# StyleCop
StyleCopReport.xml
@@ -61,6 +76,7 @@ StyleCopReport.xml
*_i.c
*_p.c
*_i.h
+*_h.h
*.ilk
*.meta
*.obj
@@ -77,6 +93,7 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
+*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
@@ -132,6 +149,11 @@ _TeamCity*
.axoCover/*
!.axoCover/settings.json
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
# Visual Studio code coverage results
*.coverage
*.coveragexml
@@ -179,6 +201,8 @@ PublishScripts/
# NuGet Packages
*.nupkg
+# NuGet Symbol Packages
+*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
@@ -203,12 +227,14 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
+*.appxbundle
+*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
-!*.[Cc]ache/
+!?*.[Cc]ache/
# Others
ClientBin/
@@ -217,10 +243,11 @@ ClientBin/
*.dbmdl
*.dbproj.schemaview
*.jfm
+*.pfx
*.publishsettings
orleans.codegen.cs
-# Including strong name files can present a security risk
+# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
@@ -251,6 +278,9 @@ ServiceFabricBackup/
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
@@ -293,6 +323,9 @@ paket-files/
# CodeRush
.cr/
+# CodeRush personal settings
+.cr/personal
+
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
@@ -316,7 +349,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/
-# Azure Stream Analytics local run output
+# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
@@ -325,7 +358,111 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser
-# MFractors (Xamarin productivity tool) working folder
+# MFractors (Xamarin productivity tool) working folder
.mfractor/
-logs/
\ No newline at end of file
+logs/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+##
+## Visual studio for Mac
+##
+
+
+# globs
+Makefile.in
+*.userprefs
+*.usertasks
+config.make
+config.status
+aclocal.m4
+install-sh
+autom4te.cache/
+*.tar.gz
+tarballs/
+test-results/
+
+# Mac bundle stuff
+*.dmg
+*.app
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
+# Windows thumbnail cache files
+Thumbs.db
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+##
+## Visual Studio Code
+##
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
diff --git a/.travis.yml b/.travis.yml
index 6df0ef1a..8cc7e1c3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,10 +2,10 @@ language: csharp
mono: none
sudo: required
dist: xenial
-dotnet: 7.0.100
+dotnet: 8.0.0
branches:
only:
- - master
+ - main
#- develop
before_script:
- chmod -R a+x scripts
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..3c87ede3
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,377 @@
+### Changelog
+
+All notable changes to this project will be documented in this file. Dates are displayed in UTC.
+
+Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
+
+#### [v6.4.0](https://github.com/Genocs/genocs-library/compare/v6.3.0...v6.4.0)
+
+> 10 November 2024
+
+- Refactor MongoDB repository structure and base classes [`98e24b1`](https://github.com/Genocs/genocs-library/commit/98e24b1aab96ca4276924a822e0b5ffec50c3e9b)
+- Update package references to version 6.4.0 across multiple projects [`6fdf470`](https://github.com/Genocs/genocs-library/commit/6fdf470b2234bf8a08e70deb251bef4f2cbd4edc)
+- Refactor: Replace IIdentifiable with IEntity [`a21e330`](https://github.com/Genocs/genocs-library/commit/a21e33004ff115b383556835096ee02bd94c9f0f)
+- Update packages, refactor code, and improve readability [`0a2d5be`](https://github.com/Genocs/genocs-library/commit/0a2d5be49e6e3d28e56da01aea2b72c21fa83568)
+- Remove project refs and add using directive [`a5f189b`](https://github.com/Genocs/genocs-library/commit/a5f189be8c47d0294ca93dea5804a11b67bcc84d)
+- Update to version 6.3.0 and refactor codebase [`713fb84`](https://github.com/Genocs/genocs-library/commit/713fb847400afccc205061d854db1ee22159d62d)
+- Standardize property names and update audit fields [`c10e995`](https://github.com/Genocs/genocs-library/commit/c10e995b229fa8958e7f0585679562c711a56c22)
+- Refactor MongoDB repository structure and update usings [`c3a8bac`](https://github.com/Genocs/genocs-library/commit/c3a8baca5d49ee7999be1e59384fea5c8b2d36d2)
+- Refactor AzureInitializer and update MongoDB.Driver [`42dfe53`](https://github.com/Genocs/genocs-library/commit/42dfe53d120dbd53fe8018bdd418f1d2d9208c0f)
+- Refactor null checks and exception handling [`7da092d`](https://github.com/Genocs/genocs-library/commit/7da092d0fecec393297dac85cf0a11e6fe6df95c)
+- Update CHANGELOG for v6.3.0 release [`2e5eb47`](https://github.com/Genocs/genocs-library/commit/2e5eb47693439d55f9974402bab3f923993f117c)
+- Update package versions in multiple project files [`106fc31`](https://github.com/Genocs/genocs-library/commit/106fc319c0411d90a6499bb4477b6f80cbe585f2)
+- Refactor Entity and IAggregateRoot for simplicity [`3ccf665`](https://github.com/Genocs/genocs-library/commit/3ccf665db0c7e8eaceb50fa13d14c1ff4faa22e6)
+
+#### [v6.3.0](https://github.com/Genocs/genocs-library/compare/v6.2.0...v6.3.0)
+
+> 3 November 2024
+
+- Update project files and package references [`34415fa`](https://github.com/Genocs/genocs-library/commit/34415fa90e252c2654ddeebf5a8f84789d29be20)
+- Update Genocs packages from 6.2.0 to 6.3.0 [`950efdb`](https://github.com/Genocs/genocs-library/commit/950efdb79522da4661f8fba43d020d07e4a6d927)
+- Update package versions to 6.2.0 in multiple projects [`328f67e`](https://github.com/Genocs/genocs-library/commit/328f67e3a0f1ceb1be16be1d7eff0c679c5e5a8e)
+- Update project references and improve domain entities [`24589b4`](https://github.com/Genocs/genocs-library/commit/24589b4a5cc52bb99609c3089b2e366343f5688e)
+- Update Roslynator.Analyzers and adjust framework references [`6e9af26`](https://github.com/Genocs/genocs-library/commit/6e9af26c48bad5298f20430eca65f06b0a2c99f4)
+- Update to 6.2.0, replace Jaeger with OpenTelemetry [`ee78547`](https://github.com/Genocs/genocs-library/commit/ee785472f89c00bb5e53ad066b9d7b8b2588fffa)
+- Update packages, enhance JWT options, and refactor configs [`ded3efb`](https://github.com/Genocs/genocs-library/commit/ded3efb09cdb4b9b42b5d36102cf45bea608e84c)
+
+#### [v6.2.0](https://github.com/Genocs/genocs-library/compare/v6.1.0...v6.2.0)
+
+> 22 October 2024
+
+- Refactor and enhance OpenAPI and middleware handling [`4bbbe88`](https://github.com/Genocs/genocs-library/commit/4bbbe8811151bcefa73254f6f2fd4eba21409c2d)
+- Update package versions in workflows and projects [`5909e0b`](https://github.com/Genocs/genocs-library/commit/5909e0b1a03d51817816cf4c1944e5fc93af32f9)
+- Update package versions to 6.2.0 in Genocs.HTTP, Genocs.Core, Genocs.Metrics, Genocs.WebApi, Genocs.Security, Genocs.Logging, Genocs.Secrets.Vault, Genocs.MessageBrokers, Genocs.WebApi.Swagger, Genocs.ServiceBusAzure, Genocs.Persistence.Redis, Genocs.Core.Demo.Contracts, Genocs.Persistence.MongoDb, Genocs.WebApi.Security, Genocs.Secrets.AzureKeyVault, Genocs.MessageBrokers.Outbox, Genocs.MessageBrokers.RabbitMQ, Genocs.Auth, Genocs.WebApi.CQRS, Genocs.Discovery.Consul, Genocs.Persistence.MongoDb.UnitTests, and Genocs.Core.Demo.Domain projects [`7a08e96`](https://github.com/Genocs/genocs-library/commit/7a08e96d7625a3aea775a325e20bc117fbb74420)
+- Add detailed Swagger configuration and options [`3ea5a05`](https://github.com/Genocs/genocs-library/commit/3ea5a05522ec98715802cd24ed1c660acd89588a)
+- Enhance Azure setup, null safety, and code quality [`21f2798`](https://github.com/Genocs/genocs-library/commit/21f27983546f3757d957c03dfef8394df95388d3)
+- Refactor: Replace Jaeger with OpenTelemetry [`4e1a3ba`](https://github.com/Genocs/genocs-library/commit/4e1a3ba54d5872421849773efe6aecfed5a1c241)
+- Update Roslynator, improve type clarity, and reformat code [`52b5851`](https://github.com/Genocs/genocs-library/commit/52b5851706ca1a0c14849f6ffc398def10b58c3b)
+
+#### [v6.1.0](https://github.com/Genocs/genocs-library/compare/v6.0.0...v6.1.0)
+
+> 11 October 2024
+
+- Refactor interfaces, update Azure Key Vault options, and improve code readability [`485db2c`](https://github.com/Genocs/genocs-library/commit/485db2ca1dd13e87a785a2242248671858fb7e45)
+- Refactor: Replace Jaeger with OpenTelemetry [`1eed44b`](https://github.com/Genocs/genocs-library/commit/1eed44bd91c9b187bcc1a2d3983ebe52b20e0664)
+- Refactor interfaces and update Azure Key Vault options [`87edca1`](https://github.com/Genocs/genocs-library/commit/87edca186850db3cbe17398229335012308fb814)
+- **List of code changes:** [`01adb18`](https://github.com/Genocs/genocs-library/commit/01adb188466e53010932b58c2475cef69afeecc1)
+- Update package versions from 6.0.* to 6.1.* [`088a59a`](https://github.com/Genocs/genocs-library/commit/088a59adc0da7fcb3676a9e08f43a3187ba4d9df)
+- Make properties nullable and improve code readability [`6e091e5`](https://github.com/Genocs/genocs-library/commit/6e091e5fa20f0a2d1dda34468675d6fbe787792c)
+- Refactor interfaces, update Azure Key Vault options, and improve code readability [`866463f`](https://github.com/Genocs/genocs-library/commit/866463f0f4abf764b667774553301a417733474d)
+- Update packages and enhance Azure Key Vault integration [`3b45172`](https://github.com/Genocs/genocs-library/commit/3b45172b945ad7df08a11021c4ef738bad715f33)
+- Remove CardToken, update configs, and add Oracle setup [`c1095a7`](https://github.com/Genocs/genocs-library/commit/c1095a76c9755976f829e77ea4051e2b84ef948a)
+- Update various NuGet packages across multiple projects [`a1e01bb`](https://github.com/Genocs/genocs-library/commit/a1e01bb0634de8d38a869fb0b75ed530cd42f1db)
+- Refactor and update dependencies, fix typos, and improve code formatting [`318ca61`](https://github.com/Genocs/genocs-library/commit/318ca61f46bb69fd29b13346576373d4d0cedd2c)
+- Refactor README.md and remove unnecessary lines [`ab02bd7`](https://github.com/Genocs/genocs-library/commit/ab02bd7d529538eee6cf60a2926b6b889853487d)
+
+### [v6.0.0](https://github.com/Genocs/genocs-library/compare/6.0.0-preview.2.0...v6.0.0)
+
+> 31 July 2024
+
+- Refactor and update dependencies and logging level [`63533a2`](https://github.com/Genocs/genocs-library/commit/63533a2ccfb64106dd81e296ca1a1de55c556f48)
+- Refactor auth and update docs [`a63d816`](https://github.com/Genocs/genocs-library/commit/a63d816a4b617246ec99b3400d019a1b46ff40b0)
+- Update packages, fix typos, and improve code formatting [`d634694`](https://github.com/Genocs/genocs-library/commit/d6346942c88195b831bd66f4ff8a1e039695e0b2)
+- Update various NuGet packages across multiple projects [`c61eab2`](https://github.com/Genocs/genocs-library/commit/c61eab254c53920f94c575503c41c4e623fd1b36)
+
+#### [6.0.0-preview.2.0](https://github.com/Genocs/genocs-library/compare/v5.0.0-preview.4.0...6.0.0-preview.2.0)
+
+> 19 July 2024
+
+- Bump prometheus-net from 5.0.2 to 8.2.1 [`#54`](https://github.com/Genocs/genocs-library/pull/54)
+- Bump System.IdentityModel.Tokens.Jwt from 7.0.3 to 7.1.2 in /src/Genocs.Auth [`#56`](https://github.com/Genocs/genocs-library/pull/56)
+- Bump Polly from 8.2.0 to 8.2.1 [`#55`](https://github.com/Genocs/genocs-library/pull/55)
+- Bump Microsoft.VisualStudio.Azure.Containers.Tools.Targets from 1.19.5 to 1.19.6 [`#53`](https://github.com/Genocs/genocs-library/pull/53)
+- Bump Moq from 4.20.69 to 4.20.70 [`#52`](https://github.com/Genocs/genocs-library/pull/52)
+- Net8 [`#35`](https://github.com/Genocs/genocs-library/pull/35)
+- Bump Serilog.Sinks.Seq from 5.1.0 to 5.2.3 [`#21`](https://github.com/Genocs/genocs-library/pull/21)
+- Bump Serilog.Sinks.ElasticSearch from 8.4.1 to 9.0.3 [`#18`](https://github.com/Genocs/genocs-library/pull/18)
+- Added documentation and more control over types [`3d4c17e`](https://github.com/Genocs/genocs-library/commit/3d4c17e0e501d9174160f01569d2523472085a04)
+- Refactor configs and update docs across projects [`504fc40`](https://github.com/Genocs/genocs-library/commit/504fc40ee05a1ed6bc838a5b08195cb285feb8c1)
+- Merge issues [`cc6c097`](https://github.com/Genocs/genocs-library/commit/cc6c097d28854b584d3df34f9dc3ea6c4be78db9)
+- Updated Nuget Packages [`9ff8abb`](https://github.com/Genocs/genocs-library/commit/9ff8abbd28df412a5e8e34b4d6e5fc26bda2046b)
+- Sincronize naming conventions [`7bae2b7`](https://github.com/Genocs/genocs-library/commit/7bae2b7496200b36a9f0f0c4f0dadf60b74c3421)
+- Updated packages [`9f04ab5`](https://github.com/Genocs/genocs-library/commit/9f04ab59052556b3f27aa3b377b08ed2b3e5e4b8)
+- Documentation, updated packages [`3d49180`](https://github.com/Genocs/genocs-library/commit/3d49180fd5bfa4d07f7297b852bee83f2b000849)
+- Refactor config naming and add new options [`5977b8c`](https://github.com/Genocs/genocs-library/commit/5977b8c49236a78a209519de00deb6e9865d7b57)
+- Updated comments, attributes, methods, and dependencies across multiple files [`ccaf4a5`](https://github.com/Genocs/genocs-library/commit/ccaf4a583373155be0186994deea15dcdabfbade)
+- Updated project dependencies and refactored security settings [`cc6bd4d`](https://github.com/Genocs/genocs-library/commit/cc6bd4df16be8fc76e4f7f68359cb1e6c1ae430e)
+- Cleanup data after uniform naming conventions [`34b35b2`](https://github.com/Genocs/genocs-library/commit/34b35b2c4979c95b957f144cf7e680d16fca450d)
+- Refactor auth/config handling and enhance security [`bb5ea59`](https://github.com/Genocs/genocs-library/commit/bb5ea5989bdbe0bfa756e3b00b1a15a3e12f3942)
+- Refactor and enhance JWT handling and security [`b864cc9`](https://github.com/Genocs/genocs-library/commit/b864cc9693111b9d60881a6643e5b16638c15894)
+- Refactor and enhance JWT handling and security [`736964d`](https://github.com/Genocs/genocs-library/commit/736964d22cb1715c3c1b0455647077a5797c99ad)
+- Integrate Azure Key Vault & Update Packages [`bd2a025`](https://github.com/Genocs/genocs-library/commit/bd2a025418302d032c93219388bc542c9c4b9409)
+- Updated multiple packages and improved code readability [`8b9b1b5`](https://github.com/Genocs/genocs-library/commit/8b9b1b58fe6d618f0621e2412934fa94e412bdf5)
+- Refactor and enhance codebase for clarity [`227e968`](https://github.com/Genocs/genocs-library/commit/227e9686af3c2f0c036c1546202e3a9d5b998a96)
+- Add verification service client and models [`3b27e46`](https://github.com/Genocs/genocs-library/commit/3b27e463fa91d72fe87473c7d6918114896433cd)
+- Updated project structure [`9ffe861`](https://github.com/Genocs/genocs-library/commit/9ffe8612bf90808a2584c3a62feb1128be2d65de)
+- Fix [`0af67b8`](https://github.com/Genocs/genocs-library/commit/0af67b813a1c7d70d5a7b5f0d3fc8fdf5e7071da)
+- Refactor code for improved readability and update variable types [`762c51f`](https://github.com/Genocs/genocs-library/commit/762c51f5b8d38ede287938fde6f0f7638eb33f75)
+- Refactor auth and update docs [`06bb32f`](https://github.com/Genocs/genocs-library/commit/06bb32ff452e1e32e94dc5554aa38c7bf7ce5ec8)
+- Minor fix [`9ad6741`](https://github.com/Genocs/genocs-library/commit/9ad67419409742bcad1f383a1f9f5219f9ccfb7a)
+- Updated nuget packages to prepare for removing legacy behavior [`3887c17`](https://github.com/Genocs/genocs-library/commit/3887c171b97543ee47e8e182e63964e6b5f8667e)
+- Reverted reference framework [`99ac637`](https://github.com/Genocs/genocs-library/commit/99ac6373f8774c73de507419425b9840928f5fde)
+- Refactored code for readability and updated variable types [`cc0d478`](https://github.com/Genocs/genocs-library/commit/cc0d47898ac8f705e9cb17837eb5f272d6a77bc2)
+- Update app config for logging, security, and more [`1058ea1`](https://github.com/Genocs/genocs-library/commit/1058ea157068e99bb9e08dbe71350d574d9b8d7f)
+- Enhanced app config and documentation [`bf42a88`](https://github.com/Genocs/genocs-library/commit/bf42a88da74ce68b2aaef9c3463ac698cc01a145)
+- Setup configuration [`02c2be7`](https://github.com/Genocs/genocs-library/commit/02c2be7978110755596ff81f95f108b6b8c61f0b)
+- Update dependencies and refactor namespaces [`0cde64f`](https://github.com/Genocs/genocs-library/commit/0cde64fba30a987d5be4062d6ab167945629b8bc)
+- updates for 2024 [`c58e4a2`](https://github.com/Genocs/genocs-library/commit/c58e4a2be076f22bec1dcad16a4f4a05a8865203)
+- Update package versions across projects [`bb92cdb`](https://github.com/Genocs/genocs-library/commit/bb92cdbb7688fa5f33c4660729b6b589c41f3e06)
+- Refactor auth and update docs [`85198fb`](https://github.com/Genocs/genocs-library/commit/85198fbd504da2e98499783f0d85eb6fcccab91d)
+- Refactor configuration naming conventions and add new options [`ede9ad3`](https://github.com/Genocs/genocs-library/commit/ede9ad3256c1ad948b89dddc789d6734ae2eed1a)
+- Merge issues [`94db485`](https://github.com/Genocs/genocs-library/commit/94db485eaf5a5732aeb300f9b1ab701835b3a256)
+- removed templates and updated packages [`aa54284`](https://github.com/Genocs/genocs-library/commit/aa542848efc453e7f298f5dd02e466d5a42c7791)
+- File updates [`73afdc0`](https://github.com/Genocs/genocs-library/commit/73afdc09e3412194d31a462ce3d63d7116ebbd68)
+- Minor fix [`2dde44c`](https://github.com/Genocs/genocs-library/commit/2dde44c057ee340bb9aebceb367f2d9cd3b084d7)
+- Version pre5.x [`7ba35a0`](https://github.com/Genocs/genocs-library/commit/7ba35a0d172d3699e58da473f41c408ee0267376)
+- Clean warnings [`7c66fc3`](https://github.com/Genocs/genocs-library/commit/7c66fc3f57bc60bf44f35e391f80a5855baba357)
+- Cleanup config file [`5a3ab6d`](https://github.com/Genocs/genocs-library/commit/5a3ab6d535046b6f35d40f682c6e3fa371905db4)
+- work in progress setup docker [`19e285e`](https://github.com/Genocs/genocs-library/commit/19e285e52b3a59cb9e6ea50414edc5fb33326df2)
+- Added comments [`7661260`](https://github.com/Genocs/genocs-library/commit/7661260ebc31ee35c5cd600b238422c281fd7e1e)
+- Updates [`eba8b20`](https://github.com/Genocs/genocs-library/commit/eba8b208039220656cb3d4cf32ac285dda13fb79)
+- Updates change log [`08f7ea0`](https://github.com/Genocs/genocs-library/commit/08f7ea0ef2212d92769c1aad6fd0af05c673e168)
+- Fix error on Console log [`f6da253`](https://github.com/Genocs/genocs-library/commit/f6da2539bd7249928d3221f0a3af95ab5dd513ef)
+- Updated Release note [`acf52b8`](https://github.com/Genocs/genocs-library/commit/acf52b8b636de43ebb91bb2ab1b4a234d2e51092)
+- Added wildcard [`bb303ea`](https://github.com/Genocs/genocs-library/commit/bb303eae19f13d330e0bc14c864e6e2fca4e001b)
+- Implemented Mongo functionality [`3bb4589`](https://github.com/Genocs/genocs-library/commit/3bb4589e3596ca7cb1aed17129a3aab2ef5b9dd5)
+- Updated packages [`9f2cedc`](https://github.com/Genocs/genocs-library/commit/9f2cedca131300bcc01183f936ef7d0a77599cb8)
+- Refactory open telemetry [`a3170e5`](https://github.com/Genocs/genocs-library/commit/a3170e5c1d1b5fd56cc0b65e3663dfaa3cb1e7b9)
+- Changed the docker compose config file [`1444175`](https://github.com/Genocs/genocs-library/commit/1444175abb79ab834bd69dcbac9395829332c3ff)
+- Fix configuration on docker without Fabio and Consul [`363ec41`](https://github.com/Genocs/genocs-library/commit/363ec41ebdc5d0f7c17a935226504c37d53b50cd)
+- Before big refactory [`b21a55e`](https://github.com/Genocs/genocs-library/commit/b21a55ec751c8186b73e7da84bd1a38256ff7984)
+- Fix link [`56b18a2`](https://github.com/Genocs/genocs-library/commit/56b18a25652e30f383b6c137a168487a3827cd5e)
+- Fix auth and authorization [`5b7fc8c`](https://github.com/Genocs/genocs-library/commit/5b7fc8cebf25b33ee7f7f676a74698aee328ca7d)
+- Using Open telemetry [`09a5783`](https://github.com/Genocs/genocs-library/commit/09a57836398b28ba07afbbadcf211181e1b86829)
+- Pagages updated wip [`dd10e1a`](https://github.com/Genocs/genocs-library/commit/dd10e1afa7a1cf6f5c7b1780413fff9ae9cd0775)
+- Second round [`8d92e64`](https://github.com/Genocs/genocs-library/commit/8d92e641cd7f3ca2cc658c36739d1253e9bc5525)
+- Default mongodb entity with ObjectId [`296abe7`](https://github.com/Genocs/genocs-library/commit/296abe7757f025b2d75313e423d9f380f758a160)
+- updated docker files and github actions [`a7dd458`](https://github.com/Genocs/genocs-library/commit/a7dd4583ac302f1841d2b1c152849deb761f3cc2)
+- updated readme [`ccb4614`](https://github.com/Genocs/genocs-library/commit/ccb46140e499cb1cac8ab129e710a9bffe0034e6)
+- Updated clients to net8 [`8f32845`](https://github.com/Genocs/genocs-library/commit/8f328458cfdc28303e78f1d87d11e98a9f348280)
+- Fix workflow [`6f527c7`](https://github.com/Genocs/genocs-library/commit/6f527c7324c6097ca287a3c1a1bcff592af081ea)
+- tmp [`7688a62`](https://github.com/Genocs/genocs-library/commit/7688a627e67555c0a5e5578e489b3ad45810e9bb)
+- Added default assembly name [`8293914`](https://github.com/Genocs/genocs-library/commit/8293914cac430f3b15921f6aa8de64619b1aac19)
+- Commit after the check with Products and Oerders by Postman [`5f37139`](https://github.com/Genocs/genocs-library/commit/5f37139b8d8eb4f5e5ce7cb6c4d8d2b147ce106e)
+- minor fix [`b5a32dd`](https://github.com/Genocs/genocs-library/commit/b5a32dd6c5256892c73f086b9686f953e6ced46a)
+- refactory [`b94aa66`](https://github.com/Genocs/genocs-library/commit/b94aa66fc60fc0d5b90fa799b95ea193bb74fe42)
+- Added auth features and AuthorizedController [`3a28fd1`](https://github.com/Genocs/genocs-library/commit/3a28fd1bf3f42c3de94cdd58ae002eb91b14fe2c)
+- fix prometheus [`3ba5662`](https://github.com/Genocs/genocs-library/commit/3ba56621b9ff9882902d8908c3e69d23cb840fa7)
+- Fix for pack [`19f2e02`](https://github.com/Genocs/genocs-library/commit/19f2e027fd0dbab7871171e6af05be8d5e10b88e)
+- Updated github action [`7b8bf5d`](https://github.com/Genocs/genocs-library/commit/7b8bf5dfb9d5bdb0c8244a52239af7707c290862)
+- Updated references [`28920e4`](https://github.com/Genocs/genocs-library/commit/28920e4c8411a90d6eb57c24f3c655715b2160c3)
+- Disabled Monitoring [`a8bad21`](https://github.com/Genocs/genocs-library/commit/a8bad21f6c199b726de89167f740bac1c85fcd6f)
+- Fix build [`8c0bdf3`](https://github.com/Genocs/genocs-library/commit/8c0bdf374e38b543bc6398d0742ad3dab66c95b7)
+- Updated log plus fix url service [`24aff9b`](https://github.com/Genocs/genocs-library/commit/24aff9b130c36c90d73a13f70e3047f42a128a76)
+- Bump System.IdentityModel.Tokens.Jwt in /src/Genocs.Auth [`cd58c28`](https://github.com/Genocs/genocs-library/commit/cd58c28d68e059fb6fb83db7d34debcdee5ee1b4)
+- Bump Microsoft.VisualStudio.Azure.Containers.Tools.Targets [`d620e5d`](https://github.com/Genocs/genocs-library/commit/d620e5d6d9a9d4a5abac0dde8ad3aeef3e2c42a6)
+- Fix path [`31a62e9`](https://github.com/Genocs/genocs-library/commit/31a62e9f428866042f6191bcf99c411dda0368b6)
+
+#### [v5.0.0-preview.4.0](https://github.com/Genocs/genocs-library/compare/v5.0.0-preview.3.0...v5.0.0-preview.4.0)
+
+> 15 July 2023
+
+- April 2023 [`#17`](https://github.com/Genocs/genocs-library/pull/17)
+- Create ml.yml [`#14`](https://github.com/Genocs/genocs-library/pull/14)
+- April 2023 [`#12`](https://github.com/Genocs/genocs-library/pull/12)
+- April 2023 [`#11`](https://github.com/Genocs/genocs-library/pull/11)
+- Preview 4.x [`d619840`](https://github.com/Genocs/genocs-library/commit/d619840033c146a60bdb5fe6f37ea7e6e7ae5de7)
+- Start removing legacy MongoDB legacy database [`f4ca960`](https://github.com/Genocs/genocs-library/commit/f4ca9609ef11ad550c789e05dbfd6c0984fa312b)
+- Refactory to remove legacy Mongodb [`7accdcb`](https://github.com/Genocs/genocs-library/commit/7accdcba26edb9e38ebf0583966348f80a2d31b1)
+- refactory template [`78a2731`](https://github.com/Genocs/genocs-library/commit/78a27316ce9a4341af3c1c21b2e9543bf8cf0af3)
+- Added Mongo Encriptation [`a6e2157`](https://github.com/Genocs/genocs-library/commit/a6e2157a9e60c6da11623e70f41657b8caa78cf3)
+- Refactory Persistance [`d27adce`](https://github.com/Genocs/genocs-library/commit/d27adce74254630bca2d0da46fec17c94372848b)
+- Fix application [`8c10982`](https://github.com/Genocs/genocs-library/commit/8c10982c42a0d176b045ea6ce22a37ff95f8abda)
+- Fix templates [`55c8d85`](https://github.com/Genocs/genocs-library/commit/55c8d8505fa33f06cfb02814734464adf384eb22)
+- Removed legacy references [`a32d92b`](https://github.com/Genocs/genocs-library/commit/a32d92b6f68c50a0638912b52a250338db59de7c)
+- Fix error on unit test [`b2f5fdd`](https://github.com/Genocs/genocs-library/commit/b2f5fdd6069bb6276fc29af312616704ac48f27a)
+- Paginated query [`ddb108e`](https://github.com/Genocs/genocs-library/commit/ddb108e6ca4d391f5a7c4b515831cddf083ec82f)
+- Updated packages [`f030660`](https://github.com/Genocs/genocs-library/commit/f03066034868d3cebb38667425e63b6d8f55b3da)
+- updates [`48b67fb`](https://github.com/Genocs/genocs-library/commit/48b67fba3bc2e2ee72d008734629b31547275d7b)
+- Updated github workflow [`8b689df`](https://github.com/Genocs/genocs-library/commit/8b689dfe7adb50f6378ed9a970ec6b9412e0a7f0)
+
+#### v5.0.0-preview.3.0
+
+> 13 May 2023
+
+- March 2023 [`#9`](https://github.com/Genocs/genocs-library/pull/9)
+- Create docker-image.yml [`#6`](https://github.com/Genocs/genocs-library/pull/6)
+- Create nuget-deploy.yml [`#5`](https://github.com/Genocs/genocs-library/pull/5)
+- Added explicitly build [`#3`](https://github.com/Genocs/genocs-library/pull/3)
+- Develop [`#2`](https://github.com/Genocs/genocs-library/pull/2)
+- Bump Microsoft.AspNetCore.Authentication.JwtBearer from 5.0.6 to 5.0.9 in /src/Genocs.Core.Demo.WebApi [`#1`](https://github.com/Genocs/genocs-library/pull/1)
+- Added SignalR service [`8a6faee`](https://github.com/Genocs/genocs-library/commit/8a6faeef4c6c2dec473abb1e86fe55a9e24f87c5)
+- Added template [`98884b0`](https://github.com/Genocs/genocs-library/commit/98884b034910bc8d4c912344fe2ce0f54b4e7aaa)
+- Upated to net7 [`2cbc3f8`](https://github.com/Genocs/genocs-library/commit/2cbc3f8b6cefb5cfe153b3aba8a28d5f425804dc)
+- First commit [`4d9b150`](https://github.com/Genocs/genocs-library/commit/4d9b1503a8295f21392886f4a149a67851472d47)
+- Users Implementation - WIP [`1b80c65`](https://github.com/Genocs/genocs-library/commit/1b80c65e26fcbe16ae15aaf42fa7b93350aca70e)
+- Added Consul, Fabio and RestEasy [`0d7e96b`](https://github.com/Genocs/genocs-library/commit/0d7e96bcdc372044b8a7b7d3705b594aa5c39b97)
+- Added WebApi [`9e28196`](https://github.com/Genocs/genocs-library/commit/9e28196b0db9a3a30d4ba8094c448020f09529c7)
+- Added Query builder [`6e1318b`](https://github.com/Genocs/genocs-library/commit/6e1318b83b09299bce1fe0d1683b67e6aa200fa7)
+- File file structure completed [`af6664e`](https://github.com/Genocs/genocs-library/commit/af6664ea893388c8acf938c3317c8d76c90c3c87)
+- Review for CQRS [`e7ec4aa`](https://github.com/Genocs/genocs-library/commit/e7ec4aa85a81b47af4c4ae3bd4ab2ce4e6adb852)
+- Added Vault [`172acbd`](https://github.com/Genocs/genocs-library/commit/172acbdc7aded226a49b642168443ca63f39241d)
+- Updated naming conventions [`a81a5de`](https://github.com/Genocs/genocs-library/commit/a81a5dec2f8fc1cda111b0451d3da310b3b410ef)
+- Genocs.Core Version 3.1 [`89675d3`](https://github.com/Genocs/genocs-library/commit/89675d3bc6b68e03628865c20ff52bee94888086)
+- Fix read options [`831e1f4`](https://github.com/Genocs/genocs-library/commit/831e1f4631a3fa244dcf3bc25ad258d8db27eb9e)
+- Added API Gateway [`78d0f16`](https://github.com/Genocs/genocs-library/commit/78d0f16b96b2900486c585f267ab7716679e320c)
+- added Azure Service bus [`6d79d68`](https://github.com/Genocs/genocs-library/commit/6d79d68ad7a4348841cc100e84c57ec63c97bef2)
+- Added WebApi.CORS and WebAPI.Security [`612b2d2`](https://github.com/Genocs/genocs-library/commit/612b2d2696894ef9f12e0410750a86069c1b8e0d)
+- Removed fix [`80e943c`](https://github.com/Genocs/genocs-library/commit/80e943c9283570a3816dcff418bb683d2e401314)
+- Build it's OK - Runting crash [`044f029`](https://github.com/Genocs/genocs-library/commit/044f0297c4d24b17da97a48196c260f987b20dee)
+- Added complete demo [`ec6427c`](https://github.com/Genocs/genocs-library/commit/ec6427c3f0ba73fb429292025f26d21598a1cf6a)
+- Added auth [`6703204`](https://github.com/Genocs/genocs-library/commit/670320401a6198b5ebb09464a2fd10cfe49d1765)
+- update version [`3973f32`](https://github.com/Genocs/genocs-library/commit/3973f3236625dad6d1c11b19b56a71fb1c24c076)
+- Refactory [`d88206b`](https://github.com/Genocs/genocs-library/commit/d88206b55a4825202ad7d2140c97087a634ca14b)
+- Implemented CQRS pattern in Core [`d2adfb8`](https://github.com/Genocs/genocs-library/commit/d2adfb8a7385bd1d6312fbb69ff8568058b6ab07)
+- Added products [`1a9fcdd`](https://github.com/Genocs/genocs-library/commit/1a9fcdd53f4aa68807b0ae7fbe5da4217ebf501f)
+- Updated Nuget plus push on nuget [`eb001d8`](https://github.com/Genocs/genocs-library/commit/eb001d899a25f212591c195cf9fd6f8cc2b00265)
+- Added web demo [`77dc809`](https://github.com/Genocs/genocs-library/commit/77dc809c3d661f08011dabf8f52fce15481ab9d7)
+- Configuration files updated for deployments [`86317d3`](https://github.com/Genocs/genocs-library/commit/86317d370287b75e4f5114ae24c9018ee47df1fd)
+- Committed after refactory [`908dee7`](https://github.com/Genocs/genocs-library/commit/908dee79e5818875f1b366d509cd9231ea20011f)
+- Clean up data [`5378f6b`](https://github.com/Genocs/genocs-library/commit/5378f6bfc60b91e7ff01578744a71896f67f787e)
+- Projects settings [`669f10f`](https://github.com/Genocs/genocs-library/commit/669f10fab3bb4f9ae99682f65697ce2285e8ebaa)
+- Split monitoring and telemetry [`8afc9bd`](https://github.com/Genocs/genocs-library/commit/8afc9bdef6ccce499ff519156099807e1545bd77)
+- Added docker compose [`415b416`](https://github.com/Genocs/genocs-library/commit/415b41621b1a0ffb3018d767a71df59e7348ee3c)
+- Start Setup dependencies [`76b2389`](https://github.com/Genocs/genocs-library/commit/76b238943e65ce2fe4f1d02a05fcfaecfdc57b4a)
+- Splitted common from core [`e58627c`](https://github.com/Genocs/genocs-library/commit/e58627c46f86933b3dc41a231882521a45b8bf0c)
+- Addes swagger [`1b90eae`](https://github.com/Genocs/genocs-library/commit/1b90eae248e267e8ac8df4de51def8f2892cbbd4)
+- Fix open telementry [`310d251`](https://github.com/Genocs/genocs-library/commit/310d25172d3f1ebc9de262cf46710186f1c7d2a9)
+- Fix naming [`f964d5e`](https://github.com/Genocs/genocs-library/commit/f964d5e61cf4b648c5386a3db6d2d7910a25c46f)
+- Removed compile warning [`82480de`](https://github.com/Genocs/genocs-library/commit/82480de6aa6368afa375244d49c6e54562512a63)
+- Refactory naming conventions [`f340235`](https://github.com/Genocs/genocs-library/commit/f34023508c5301f9a1b197caccb35094295bd06f)
+- Added security [`09a7102`](https://github.com/Genocs/genocs-library/commit/09a7102c1cad10a67e24a86ddca20452a6cda5ef)
+- Added Mongodb [`dc0b989`](https://github.com/Genocs/genocs-library/commit/dc0b989f9d9ed23b68cee3023327228075c435e5)
+- Fix Runtime error on outbox, there is an issue on get AppSettings [`371d754`](https://github.com/Genocs/genocs-library/commit/371d7545d468a057a5c7fdb52fc5f06671434d1c)
+- added api service to service [`b8b00b9`](https://github.com/Genocs/genocs-library/commit/b8b00b9b66096175509689c3683b7214b6097295)
+- Added kubernes deplyments [`d9325b2`](https://github.com/Genocs/genocs-library/commit/d9325b216e8de992ae0fa85a413628e3d1633f8e)
+- Completed the docker container applicaion tests [`33581e4`](https://github.com/Genocs/genocs-library/commit/33581e44202235fb424d15d28fbe210ca0147030)
+- Released on Nuget [`74b71d3`](https://github.com/Genocs/genocs-library/commit/74b71d3cf70fc1251398681fffc7e63aab421185)
+- Added support for NET6 as well [`1035cd2`](https://github.com/Genocs/genocs-library/commit/1035cd2580405fe25fb2b5e8fa37eb10fde4e361)
+- Fix namespaces [`df48cc0`](https://github.com/Genocs/genocs-library/commit/df48cc014ea75907ed03b986cc553faeaac9db45)
+- Sync libraries [`1b8a059`](https://github.com/Genocs/genocs-library/commit/1b8a059a159a63abd9122fec4fbf36efd7cde98d)
+- Added bus worker [`ee5627a`](https://github.com/Genocs/genocs-library/commit/ee5627a3c79e6534f8757ebbc87fe64e79ac777a)
+- foolish updates [`e8f4bb8`](https://github.com/Genocs/genocs-library/commit/e8f4bb86b4fbaf42483c3705d685d7af1e572f27)
+- Build release [`d6cd11b`](https://github.com/Genocs/genocs-library/commit/d6cd11b36d33d21b7a0fcc69b63673ea080041da)
+- Added masstransit hosted service [`71d1f40`](https://github.com/Genocs/genocs-library/commit/71d1f40e7d9009bc7a30feecca60a4a34ac808f7)
+- Fix run SignalR [`1d5b669`](https://github.com/Genocs/genocs-library/commit/1d5b6690cab6d53099ee35b7eba1d52ff37eac12)
+- Persistence MongoDB 3.0.1 released [`a44893c`](https://github.com/Genocs/genocs-library/commit/a44893c95af0413a961e9a3a1e7cc2b5fe7e0a80)
+- Updated library [`99502ff`](https://github.com/Genocs/genocs-library/commit/99502ffb74ee1d828ad10649a4b25f7a9d85f2a6)
+- minor fix [`ca3b995`](https://github.com/Genocs/genocs-library/commit/ca3b99552a202dc79041207848dea69800c4856b)
+- Fix monitoring and tracing [`5ca3d46`](https://github.com/Genocs/genocs-library/commit/5ca3d4638788a3564f94fb156000fde6ae79572a)
+- Added AzureService Bus handler [`df5f7e5`](https://github.com/Genocs/genocs-library/commit/df5f7e5a97c038d5a659bc524214109b1a586c50)
+- Document Update [`974ab14`](https://github.com/Genocs/genocs-library/commit/974ab144d3de2fae312301448ae76145652a4d99)
+- Fixed signalR [`c03535b`](https://github.com/Genocs/genocs-library/commit/c03535b12a9eff2f31a3f10976af149c4d5e89e0)
+- Refactory for docker build [`35c06cc`](https://github.com/Genocs/genocs-library/commit/35c06cc104b47aa380473b5de2fe7a98be9f1aa4)
+- New Release on Nuget [`766a5d8`](https://github.com/Genocs/genocs-library/commit/766a5d804c9c1fb0d2a5c4d43d97e967bebab486)
+- updated nuget packages [`c3eb63e`](https://github.com/Genocs/genocs-library/commit/c3eb63e72fa31223830cdde3778b73a90ad181f1)
+- Updates [`333fbeb`](https://github.com/Genocs/genocs-library/commit/333fbeb71deb1b2a46ec9e1d521de6428fdcbb4e)
+- Code cleanup [`d780d09`](https://github.com/Genocs/genocs-library/commit/d780d09eafedd42b55599509ae3bdb0ae877391d)
+- Add jwt [`594b8f8`](https://github.com/Genocs/genocs-library/commit/594b8f8dcee2414fe569751a3b128c38227b03b0)
+- Updated nuget services [`cf8ff75`](https://github.com/Genocs/genocs-library/commit/cf8ff75dfd5c7b27a7d7e8dcad4d302d6403594b)
+- Added command [`81d0f09`](https://github.com/Genocs/genocs-library/commit/81d0f090f49036c7063e181627583fd410bb89b1)
+- Changed readme filename [`7689dca`](https://github.com/Genocs/genocs-library/commit/7689dca4d7e29c2e13ef586fcd6a850c94264880)
+- Cleanup data [`d8e270e`](https://github.com/Genocs/genocs-library/commit/d8e270eed46c5f7726b62d8bfc0c86a1747fb4c0)
+- fix signalR [`a35dc64`](https://github.com/Genocs/genocs-library/commit/a35dc643b1c8f64a2521ec6b30518d83d3e5b75f)
+- Removed launch [`0430d66`](https://github.com/Genocs/genocs-library/commit/0430d6632d5d50f06c23ad3f42992b12c56bf835)
+- WIP [`ffec644`](https://github.com/Genocs/genocs-library/commit/ffec64431484fb3854317bf176bd5f38ab96e46c)
+- Refactory naming conventions [`227b8c3`](https://github.com/Genocs/genocs-library/commit/227b8c344e8f7dc889e710de9959f05fc8ba9c26)
+- Fix copy and paste typos [`d29576d`](https://github.com/Genocs/genocs-library/commit/d29576dfd7002412f3bc6f25ad7b26be24e780d4)
+- Updated Readme [`3d52b4e`](https://github.com/Genocs/genocs-library/commit/3d52b4eb1368e737c40b95a735bf17931e38ad95)
+- Minor updates [`1d5b26c`](https://github.com/Genocs/genocs-library/commit/1d5b26c3ce70434a94007db8038974fa19231cfa)
+- Enable communication between ApiGateway and service [`17e85f3`](https://github.com/Genocs/genocs-library/commit/17e85f344fdeca17eea225a0389f097fb4aabebc)
+- Template fix [`108afb7`](https://github.com/Genocs/genocs-library/commit/108afb7a1950804d4fefd322bbf03b12a796e070)
+- tmp [`5436cf9`](https://github.com/Genocs/genocs-library/commit/5436cf92e5d15febf1dc9dc0e4c195f44c8caec7)
+- Added localhost certificates [`71e14b6`](https://github.com/Genocs/genocs-library/commit/71e14b6c471fbc45c91a3d7377825119feba96ca)
+- Namespace updates [`e832ec2`](https://github.com/Genocs/genocs-library/commit/e832ec20865c711732cf6e530a7a2c83ea2a1bc2)
+- Extensions plus placeholder for documentation [`db01f6e`](https://github.com/Genocs/genocs-library/commit/db01f6ebb777e07c350fd3dcadbfcdd18c738e21)
+- Fix unit test [`28bf234`](https://github.com/Genocs/genocs-library/commit/28bf2345e57ca7a1b785fc561f820cd17b5788b0)
+- Refactory and Standardization [`198a4ef`](https://github.com/Genocs/genocs-library/commit/198a4ef419517dc15b50ecebbba89830e6f76d86)
+- Fixed project to build in Release [`b60f331`](https://github.com/Genocs/genocs-library/commit/b60f331469ec70ff37920baec5657dfb24b9b6f9)
+- fix for build and up [`ec855c7`](https://github.com/Genocs/genocs-library/commit/ec855c7c36a7aacaa918180111706fc30ea42d83)
+- Fix build docker file [`4edfb28`](https://github.com/Genocs/genocs-library/commit/4edfb2874a1e592e66688d475b93141ce9149514)
+- Cleanup [`c564e0a`](https://github.com/Genocs/genocs-library/commit/c564e0a14d4ce4971cb55abc2e3bb459f2c2c1e5)
+- Updates 2023 [`65a783a`](https://github.com/Genocs/genocs-library/commit/65a783a4c683bb647c70c1f5c7bedf8eab2635cf)
+- updated packages [`fd847a3`](https://github.com/Genocs/genocs-library/commit/fd847a3b46a813a47daebe55849fb7f48d78aa58)
+- Fix nuget packages [`41fc96c`](https://github.com/Genocs/genocs-library/commit/41fc96c675586f82d91af62c28738e6521bf02e7)
+- updated readme [`928bb26`](https://github.com/Genocs/genocs-library/commit/928bb261c4e458ec8351cebf7d1cc8231f30f84f)
+- added nuspec [`5cc6a99`](https://github.com/Genocs/genocs-library/commit/5cc6a9994bdccbba3ad8a116fc1599c081daafb3)
+- Initial commit [`d678e72`](https://github.com/Genocs/genocs-library/commit/d678e722365d1c5a6591dd776dbb7112accc0d1b)
+- added files [`5a6dd39`](https://github.com/Genocs/genocs-library/commit/5a6dd3979e76199fa329cb0e5ae7793ab0974007)
+- removed duplicated [`aea2e5e`](https://github.com/Genocs/genocs-library/commit/aea2e5e060b3ac4dba64061a04f29c9da2676d33)
+- Readme updates [`f971283`](https://github.com/Genocs/genocs-library/commit/f971283d32aca19fd9268b8a5465e1060c9130eb)
+- Added support for console hosted service plus rebuild to rc1.1 [`2fcf79a`](https://github.com/Genocs/genocs-library/commit/2fcf79a33a42fae1622c9086222fcb48a775e63a)
+- SignalR Setup completed [`57f8694`](https://github.com/Genocs/genocs-library/commit/57f869470812a3c2c1686e221887c62290da1756)
+- Added preview on package [`20a72cb`](https://github.com/Genocs/genocs-library/commit/20a72cbadda98a8244c4a1ca56e8287fe6029ba0)
+- New architecture [`5b693db`](https://github.com/Genocs/genocs-library/commit/5b693dbe7a66662bf47b064ba4147e5b4274745a)
+- minor fix on documentation [`9e08077`](https://github.com/Genocs/genocs-library/commit/9e08077f50321b8ff903a3b8c04ae958dc085942)
+- updated packages [`1961ed1`](https://github.com/Genocs/genocs-library/commit/1961ed1d9d4cc4c791e4be03d4ee3b3ccc1237c1)
+- minor changes [`f69c864`](https://github.com/Genocs/genocs-library/commit/f69c8641983e94461a999f45fefd330bd2fef68b)
+- Convey Latest version [`f381cc0`](https://github.com/Genocs/genocs-library/commit/f381cc08a8421c2e8f6eb683581cb167baf67c74)
+- Create nuget-publish.yml [`c880398`](https://github.com/Genocs/genocs-library/commit/c880398feb9bf65fea01a0becfa0b4d3e9d558c2)
+- Extended pagination [`7a4f64b`](https://github.com/Genocs/genocs-library/commit/7a4f64b30e29a8b51a6046a45616dcf9b9f7d5a4)
+- Updated packages [`c974b2f`](https://github.com/Genocs/genocs-library/commit/c974b2f93d44486f1e5c61141c576265fbe4b2e9)
+- bug fix [`23e55e2`](https://github.com/Genocs/genocs-library/commit/23e55e2dbe8fe1f16ace837e81122bd19ca6e1ab)
+- Create manual.yml [`08a5bf4`](https://github.com/Genocs/genocs-library/commit/08a5bf4b1ac0ad43ead33a7d78aca3e00da9ccf6)
+- Updated github actions [`610ae7a`](https://github.com/Genocs/genocs-library/commit/610ae7af5ef35f77361353168c8290f14e106e17)
+- Skip pack [`5f0e1a6`](https://github.com/Genocs/genocs-library/commit/5f0e1a609ebffaa806f87c1de033e3e1158ffc87)
+- Updated DDSettings to MongoDbSettings [`78867ef`](https://github.com/Genocs/genocs-library/commit/78867ef90b247a5c31b40b101771876e93cf0f60)
+- Create build_and_test.yml [`b5d6356`](https://github.com/Genocs/genocs-library/commit/b5d63563be406b3e33b0bfe953db8301b8907f3b)
+- case [`1410f79`](https://github.com/Genocs/genocs-library/commit/1410f799761a1ca552cc290a38ccfdbcff4ea069)
+- Fix product settings file [`1c9bfb7`](https://github.com/Genocs/genocs-library/commit/1c9bfb77ac9f270ece594b737bb299b96da94c11)
+- Fix nuget [`49ff439`](https://github.com/Genocs/genocs-library/commit/49ff439e01e9822a528995cb07df3a79c166cfd2)
+- updated pack [`7fda8e3`](https://github.com/Genocs/genocs-library/commit/7fda8e359aa701d729b1e361f8aca6cae77276ea)
+- Another fix [`5945ba0`](https://github.com/Genocs/genocs-library/commit/5945ba0df066de1413b818380733751d3f9b20f4)
+- Added MongoDbSettings validation [`fdd53a4`](https://github.com/Genocs/genocs-library/commit/fdd53a4507acb9ac4198ce1ebbd89118219cca6b)
+- Removed service discovery [`1fa0490`](https://github.com/Genocs/genocs-library/commit/1fa0490c7cf83daf912da12c894a8ae0868390f0)
+- Fix naming case [`5140f99`](https://github.com/Genocs/genocs-library/commit/5140f99bd6125e38ba3f93eb49d1834a5d288c00)
+- updated the readme file [`9d08b32`](https://github.com/Genocs/genocs-library/commit/9d08b3274253a68020d9c2717bdc5befde17058d)
+- Updated namespace [`460fa3a`](https://github.com/Genocs/genocs-library/commit/460fa3a7508c93e0807d0ae039046efdc6db7ada)
+- Restored package creation [`aba219a`](https://github.com/Genocs/genocs-library/commit/aba219a4c34fac787d100949e4aa010766a26c15)
+- Enabled metrics [`9323ce3`](https://github.com/Genocs/genocs-library/commit/9323ce30c4df515c8fef902472034ce46bc8f270)
+- another [`d75abd6`](https://github.com/Genocs/genocs-library/commit/d75abd63e45f249a40e8dcd07f6d28bbf00c7ae5)
+- updated Git Actions [`ab039cb`](https://github.com/Genocs/genocs-library/commit/ab039cb3fe2f1d9ab3e7b8b68b8d7634fcec9673)
+- Update README.md [`0968315`](https://github.com/Genocs/genocs-library/commit/0968315e31a156617be2fb248b8694d0003c6cf1)
+- Persistence MongoDB Release 3.1.1 [`1096f4b`](https://github.com/Genocs/genocs-library/commit/1096f4bc44d4ef443584fa33e174666f3a5c4dc8)
+- Update README.md [`db02cea`](https://github.com/Genocs/genocs-library/commit/db02cea5ea6b58eba1590ee4302364654abe09b4)
+- Fix git action [`edcc0eb`](https://github.com/Genocs/genocs-library/commit/edcc0eb2d19910b148c37f638e7bbb9eda5b28e3)
+- Minor fix [`c3e46d0`](https://github.com/Genocs/genocs-library/commit/c3e46d013c5248694996ad19cdc0bfb1234baccd)
+- updated and push on NuGet [`f6b5c65`](https://github.com/Genocs/genocs-library/commit/f6b5c65afd7f0739ca448d2ee390e38c5ad74bcc)
+- Fix missing namespaces [`11582e2`](https://github.com/Genocs/genocs-library/commit/11582e2b6ef9e507f9cf3712e23307024a009086)
+- minor updates [`3a6cff2`](https://github.com/Genocs/genocs-library/commit/3a6cff26590274f44dab563d16328be3c6a68561)
+- Updated to net 7 [`09f258c`](https://github.com/Genocs/genocs-library/commit/09f258cc977d63e2592bdd7f0ad8a3de94b14d24)
+- updated versions [`1e82df3`](https://github.com/Genocs/genocs-library/commit/1e82df394f3def006ad6146ed4edc808c58ece28)
+- Updated copyright [`38abc87`](https://github.com/Genocs/genocs-library/commit/38abc8781162853519f402b46e958dee1b56bcd8)
+- another check [`3daed28`](https://github.com/Genocs/genocs-library/commit/3daed28b821c4a33797947878b01c228b4495942)
+- Cleanup [`a80ff56`](https://github.com/Genocs/genocs-library/commit/a80ff568a5768af5ffec176b36092be30331e633)
+- updated actions [`c44d885`](https://github.com/Genocs/genocs-library/commit/c44d8857f6e5dc6bdf7f5257b659ac018577a554)
+- Fix out folder [`b3d51aa`](https://github.com/Genocs/genocs-library/commit/b3d51aa76066b400768356d5d485af26db525abf)
+- Minor fix [`2b6d56a`](https://github.com/Genocs/genocs-library/commit/2b6d56ae702a9c1cf8184e2ccedb37a42a066136)
+- Updates packages [`7e9ea75`](https://github.com/Genocs/genocs-library/commit/7e9ea7588dfa3fdd35798740e2ca5654e018b73a)
+- another fix [`b341ea9`](https://github.com/Genocs/genocs-library/commit/b341ea9eb3c3579c15782e67df1f769fd30ccd34)
+- prerelease version [`10ecc45`](https://github.com/Genocs/genocs-library/commit/10ecc45f534e5460309a39bc6b6b8c98225fbecd)
+- Update manual.yml [`dd83b4f`](https://github.com/Genocs/genocs-library/commit/dd83b4fe355bdcad206b00d88ef972027353d101)
+- enabled build nuget [`79ddbaa`](https://github.com/Genocs/genocs-library/commit/79ddbaa242c9692850fcf3f2aed7132921563732)
+- Update README.md [`dbb5ad1`](https://github.com/Genocs/genocs-library/commit/dbb5ad1ec63e5f98c2b0dfc1a56e08479b18cdd8)
+- another fix [`fc4a5e3`](https://github.com/Genocs/genocs-library/commit/fc4a5e31b159b02677ccb162da36365ca8088718)
+- Update genocs.sln [`f9a8a44`](https://github.com/Genocs/genocs-library/commit/f9a8a4412c69334876ef7b448d7a859ed6952feb)
+- Rename Genocs.Persistence.MongoDb.UnitTests.csproj to Genocs.Persistence.MongoDB.UnitTests.csproj [`c01d12a`](https://github.com/Genocs/genocs-library/commit/c01d12ad403bdea18df049af1f766c251bbc08aa)
+- --no-symbols true [`c796cec`](https://github.com/Genocs/genocs-library/commit/c796cec8f8744e4cca00bc5794724fece0cba787)
+- Fix Typo [`154f1f2`](https://github.com/Genocs/genocs-library/commit/154f1f2131c5c66d961a9cdf9f8c868f24989866)
+- updated push nuget [`6f3038d`](https://github.com/Genocs/genocs-library/commit/6f3038d0b848795456f0baa517799c0b03b84071)
+- updated nuget package [`dca2bd3`](https://github.com/Genocs/genocs-library/commit/dca2bd340733b670b9a4ee6134878fda59cf4982)
+- Fix secret [`88749b3`](https://github.com/Genocs/genocs-library/commit/88749b3edeac981bfd4edff32df16d15de4bde60)
+- Modify settings [`fca6a4e`](https://github.com/Genocs/genocs-library/commit/fca6a4ec1283eeea3890daa9a05086ab95651da2)
+- minor fix [`dfa6a0d`](https://github.com/Genocs/genocs-library/commit/dfa6a0d366b2a2f9700a3026b49f800e7a592ff7)
+- Fix version [`050265a`](https://github.com/Genocs/genocs-library/commit/050265ad33ea0cb0a3d8dfae4083aabd74260136)
+- Update README.md [`4519f74`](https://github.com/Genocs/genocs-library/commit/4519f742a570e61463a48318b0cf91a2ce96e224)
+- Update manual.yml [`cac36ca`](https://github.com/Genocs/genocs-library/commit/cac36cae9243c6fd4e56bd35c4775bb586243ba9)
+- Update manual.yml [`8d4b4b4`](https://github.com/Genocs/genocs-library/commit/8d4b4b4c7db071be08e11a1408119f69139688f5)
+- Update build_and_test.yml [`0d3eba5`](https://github.com/Genocs/genocs-library/commit/0d3eba579054975364bd26b7289bc7463cd28438)
+- Bump Microsoft.AspNetCore.Authentication.JwtBearer [`0a3c697`](https://github.com/Genocs/genocs-library/commit/0a3c6970fc1630ec5eded4692c148bbb208a61af)
+- pack [`4dfae77`](https://github.com/Genocs/genocs-library/commit/4dfae7789e1285ba60a2aea3b99186182adfcdff)
+- updated pack [`3b66046`](https://github.com/Genocs/genocs-library/commit/3b660468260fbb05a61f7676e3ab6a7bc500d8c9)
+- commentd test [`b785f88`](https://github.com/Genocs/genocs-library/commit/b785f88944eeaa931fd1edbca827cdb9b669aa33)
+- updated sdk [`08a07f5`](https://github.com/Genocs/genocs-library/commit/08a07f5093b766dc043f6e29c5546b41852686fc)
+- updated dotnet version [`e869b6f`](https://github.com/Genocs/genocs-library/commit/e869b6f05723a30e2f30ae5762970203b971fc19)
+- Fix travis [`87659ed`](https://github.com/Genocs/genocs-library/commit/87659ed017917485c4ab7f7f929aa6c650b6b1ad)
+- changed build path [`2e5d97b`](https://github.com/Genocs/genocs-library/commit/2e5d97b2035b7e8f252243062b7bf010bed5fa36)
+- Added file [`b8e3ca2`](https://github.com/Genocs/genocs-library/commit/b8e3ca2bf24ef1db66f90451023b3981feff65f4)
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000..5d2f3da5
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,128 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+info@genocs.com.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series
+of actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or
+permanent ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within
+the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
+
+Community Impact Guidelines were inspired by [Mozilla's code of conduct
+enforcement ladder](https://github.com/mozilla/diversity).
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see the FAQ at
+https://www.contributor-covenant.org/faq. Translations are available at
+https://www.contributor-covenant.org/translations.
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..49772f3a
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,77 @@
+
+
+
+
+ enable
+ enable
+ true
+ false
+ false
+ $(MSBuildThisFileDirectory)dotnet.ruleset
+ True
+ True
+ 6.3.0
+ 10.0
+ Genocs
+ Genocs 2024
+ LICENSE
+ https://github.com/Genocs/genocs-library
+ https://github.com/Genocs/genocs-library.git
+ icon.png
+ git
+ True
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+ True
+ \
+
+
+ True
+ \
+
+
+ True
+ \
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
new file mode 100644
index 00000000..fd9797bc
--- /dev/null
+++ b/Directory.Build.targets
@@ -0,0 +1,5 @@
+
+
+ $(OutputPath)$(AssemblyName).xml
+
+
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index b5d2cb0b..e9e6d445 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2023 Genocs Services
+Copyright (c) 2024 Genocs Services
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..d01ff741
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+build:
+ dotnet build
+start:
+ dotnet run --project ./src/Genocs.TelegramIntegration.WebApi
+nuget:
+ nuget pack -NoDefaultExcludes -OutputDirectory nupkgs
+publish:
+ dotnet publish --os linux --arch x64 -c Release --self-contained
+publish-to-hub:
+ dotnet publish --os linux --arch x64 -c Release -p:ContainerRegistry=docker.io -p:ContainerImageName=genocs/telegram_integration-webapi --self-contained
+tp: # terraform plan
+ cd terraform/environments/staging && terraform plan
+ta: # terraform apply
+ cd terraform/environments/staging && terraform apply
+td: # terraform destroy
+ cd terraform/environments/staging && terraform destroy
+dcu: # docker-compose up : webapi + postgresql
+ cd docker-compose/ && docker-compose -f docker-compose.postgresql.yml up -d
+dcd: # docker-compose down : webapi + postgresql
+ cd docker-compose/ && docker-compose -f docker-compose.postgresql.yml down
+fds: # force rededeploy aws ecs service
+ aws ecs update-service --force-new-deployment --service dotnet-webapi --cluster genocs
+gw: # git docker workflow to push docker image to the repository based on the main branch
+ @echo triggering github workflow to push docker image to container
+ @echo ensure that you have the gh-cli installed and authenticated.
+ gh workflow run dockerhub-publish -f push_to_docker=true
\ No newline at end of file
diff --git a/NuGet.config b/NuGet.config
index 4dfe59d3..a552551f 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -1,7 +1,6 @@
-
diff --git a/README.md b/README.md
index 7bb7c68f..5faf79c1 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,51 @@
-# Genocs .NET library
+
+[![License][license-shield]][license-url]
+[![Build][build-shield]][build-url]
+[![Downloads][downloads-shield]][downloads-url]
+[![Contributors][contributors-shield]][contributors-url]
+[![Forks][forks-shield]][forks-url]
+[![Stargazers][stars-shield]][stars-url]
+[![Issues][issues-shield]][issues-url]
+[![Discord][discord-shield]][discord-url]
+[![Gitter][gitter-shield]][gitter-url]
+[![Twitter][twitter-shield]][twitter-url]
+[![Twitterx][twitterx-shield]][twitterx-url]
+[![LinkedIn][linkedin-shield]][linkedin-url]
+
+[license-shield]: https://img.shields.io/github/license/Genocs/genocs-library?color=2da44e&style=flat-square
+[license-url]: https://github.com/Genocs/genocs-library/blob/main/LICENSE
+[build-shield]: https://github.com/Genocs/genocs-library/actions/workflows/build_and_test.yml/badge.svg?branch=main
+[build-url]: https://github.com/Genocs/genocs-library/actions/workflows/build_and_test.yml
+[downloads-shield]: https://img.shields.io/nuget/dt/Genocs.Microservice.Template.svg?color=2da44e&label=downloads&logo=nuget
+[downloads-url]: https://www.nuget.org/packages/Genocs.Microservice.Template
+[contributors-shield]: https://img.shields.io/github/contributors/Genocs/genocs-library.svg?style=flat-square
+[contributors-url]: https://github.com/Genocs/genocs-library/graphs/contributors
+[forks-shield]: https://img.shields.io/github/forks/Genocs/genocs-library?style=flat-square
+[forks-url]: https://github.com/Genocs/genocs-library/network/members
+[stars-shield]: https://img.shields.io/github/stars/Genocs/genocs-library.svg?style=flat-square
+[stars-url]: https://img.shields.io/github/stars/Genocs/genocs-library?style=flat-square
+[issues-shield]: https://img.shields.io/github/issues/Genocs/genocs-library?style=flat-square
+[issues-url]: https://github.com/Genocs/genocs-library/issues
+[discord-shield]: https://img.shields.io/discord/1106846706512953385?color=%237289da&label=Discord&logo=discord&logoColor=%237289da&style=flat-square
+[discord-url]: https://discord.com/invite/fWwArnkV
+[gitter-shield]: https://img.shields.io/badge/chat-on%20gitter-blue.svg
+[gitter-url]: https://gitter.im/genocs/
+[twitter-shield]: https://img.shields.io/twitter/follow/genocs?color=1DA1F2&label=Twitter&logo=Twitter&style=flat-square
+[twitter-url]: https://twitter.com/genocs
+[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
+[linkedin-url]: https://www.linkedin.com/in/giovanni-emanuele-nocco-b31a5169/
+[twitterx-shield]: https://img.shields.io/twitter/url/https/twitter.com/genocs.svg?style=social
+[twitterx-url]: https://twitter.com/genocs
+
+
+
+
+
-[](https://github.com/Genocs/genocs-library/blob/main/LICENSE)
-[](https://github.com/Genocs/genocs-library/actions/workflows/build_and_test.yml)
-[](https://www.nuget.org/packages/Genocs.Core)
-[](https://www.nuget.org/packages/Genocs.Core)
-[](https://discord.com/invite/fWwArnkV)
-[](https://twitter.com/genocs)
+# Genocs .NET library
----
-This repo contains a set of libraries designed by Genocs. The libraries are built using .NET standard 2.1, .NET6 and .NET7.
+This repo contains a set of libraries to build LOB (Line Of Business) applications. The library is open source and built to be PRODUCTION READY. The library is built on top of .NET8, it is designed and maintained by Genocs.
Packages are available on [NuGet Genocs](https://www.nuget.org/profiles/gioema_nocco).
@@ -23,60 +59,82 @@ Building a software library to be cloud agnostic has several advantages. First,
The advantages of using containers are numerous. Containers provide a lightweight, portable, and isolated environment for applications to run in, allowing them to be easily moved between different systems. This makes it easier to deploy applications quickly and reliably across different environments. Additionally, containers can help reduce resource consumption by running multiple applications on the same host, as each container is isolated from the others. This helps to improve efficiency and scalability. Finally, containers provide an additional layer of security, as they are isolated from the underlying operating system and other applications.
+## Documentation
+
+You can find a useful documentation about how to use the library. The documentation contains the complete set of libraries, template, CLI that altogether make the *genocs ecosystem* a comprensive set of tools to build enterprise solutions.
+
+Documentation available at [Genocs Blog](https://genocs-blog.netlify.app/library/)
+
## Infrastructure
-In this section you can find the infrastructure components to setup the environment.
-You will use ***Docker compose*** to setup the infrastructure components.
+In this section you can find the infrastructure components you need to execute the solution. Infrastucture components are the database, the enterprice servise bus, the distributed logging, monitoring, tracing systems along with database and many more.
+You can use **Docker compose** to setup the infrastructure components just by running few commands.
``` bash
+cd ./containers
# Setup the infrastructure
-docker-compose -f ./containers/infrastructure-bare.yml --project-name genocs-infrastructure up -d
-docker-compose -f ./containers/infrastructure-monitoring.yml --project-name genocs-infrastructure up -d
-docker-compose -f ./containers/infrastructure-scaling.yml --project-name genocs-infrastructure up -d
-docker-compose -f ./containers/infrastructure-security.yml --project-name genocs-infrastructure up -d
+docker compose -f ./infrastructure-bare.yml --env-file ./.env --project-name genocs up -d
+docker compose -f ./infrastructure-monitoring.yml --env-file ./.env --project-name genocs up -d
+docker compose -f ./infrastructure-scaling.yml --env-file ./.env --project-name genocs up -d
+docker compose -f ./infrastructure-security.yml --env-file ./.env --project-name genocs up -d
# Use this file only in case you want to setup sqlserver database (no need if you use postgres)
-docker-compose -f ./containers/infrastructure-sqlserver.yml --project-name genocs-infrastructure up -d
+docker compose -f ./infrastructure-sqlserver.yml --env-file ./.env --project-name genocs up -d
+
+# Use this file only in case you want to setup mySql database (no need if you use postgres)
+docker compose -f ./infrastructure-mysql.yml --env-file ./.env --project-name genocs up -d
+
+# Use this file only in case you want to setup oracle database (no need if you use postgres)
+docker compose -f ./infrastructure-oracle.yml --env-file ./.env --project-name genocs up -d
# Use this file only in case you want to setup elk stack
-docker-compose -f ./containers/infrastructure-elk.yml --project-name genocs-infrastructure up -d
+docker compose -f ./infrastructure-elk.yml --env-file ./.env --project-name genocs up -d
# Use this file only in case you want to setup AI ML components prepared by Genocs
-docker-compose -f ./containers/infrastructure-ml.yml --project-name genocs-infrastructure up -d
+docker compose -f ./infrastructure-ml.yml --env-file ./.env --project-name genocs up -d
```
-`infrastructure-bare.yml` allows to install the basic infrastructure components. Basic componens are the [RabbitMQ](https://rabbitmq.com), [Redis](https://redis.io), [Mongo](https://mongodb.com), [Postgres](https://www.postgresql.org/).
+`infrastructure-bare.yml` allows to install the basic infrastructure components. They are:
+- [RabbitMQ](https://rabbitmq.com)
+- [Redis](https://redis.io)
+- [MongoDB](https://mongodb.com)
+- [Postgres](https://www.postgresql.org/).
+You can run them locally:
-- [rabbitmq](http://localhost:15672/)
-- redis
-- mongo
-- postgresql
+- [RabbitMQ](http://localhost:15672): `localhost:15672`
+- Redis: `localhost:6379`
+- MongoDB: `localhost:27017`
+- Postgres: `localhost:5432`
-`infrastructure-monitoring.yml` allows to install the monitoring infrastructure components.
+`infrastructure-monitoring.yml` allows to install the monitoring infrastructure components. They are:
+- [Prometheus](https://prometheus.io/)
+- [Grafana](https://grafana.com/)
+- [InfluxDB](https://www.influxdata.com/)
+- [Jaeger](https://www.jaegertracing.io/)
+- [Seq](https://datalust.co/seq)
-Inside the file you can find:
-- prometheus
-- grafana
-- influxdb
-- jaeager
-- seq
+You can run them locally:
-`infrastructure-scaling.yml` allows to install the scaling infrastructure components.
+- [Prometheus](localhost:9090): `localhost:9090`
+- [Grafana](localhost:3000): `localhost:3000`
+- [InfluxDB](localhost:8086): `localhost:8086`
+- [Jaeger](localhost:16686): `localhost:16686`
+- [Seq](localhost:5341): `localhost:5341`
-Inside the file you can find:
-- fabio
-- consul
+`infrastructure-scaling.yml` allows to install the scaling infrastructure components. They are:
+- Fabio
+- Consul
`infrastructure-security.yml` allows to install the security infrastructure components.
Inside the file you can find:
-- vault (hashicorp)
+- vault (Hashicorp)
The script below allows to setup the infrastructure components. This means that you can find all the containers inside the same network.
@@ -91,32 +149,16 @@ networks:
Remember to add the network configuration inside your docker compose file to setup the network, before running the containers.
-``` yml
-networks:
- genocs:
- name: genocs-network
- external: true
- driver: bridge
-```
## ***Kubernetes cluster***
You can setup the application inside a Kubernetes cluster.
-Check the repo [enterprise-containers](https://github.com/Genocs/enterprise-containers) to setup a Kubernetes cluster.
-
-Inside the repo you can find scripts, configuration files and documentation to setup a cluster from scratch.
-
-## **Libraries**
-You can find a full documentation on:
-[**Documentation**](https://genocs-blog.netlify.app/library/)
-
-
+Check the repo [enterprise-containers](https://github.com/Genocs/enterprise-containers) to setup a Kubernetes cluster.
+There you can find scripts, configuration files and documentation to setup a cluster from scratch.
## Support
-
-
Use [**api-workbench**](./api-workbench.rest) inside Visual Studio code with [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) plugin
## Configuration
@@ -197,13 +239,15 @@ Use [**api-workbench**](./api-workbench.rest) inside Visual Studio code with [RE
"tags": {}
},
"jaeger": {
- "enabled": false,
- "serviceName": "users",
- "udpHost": "localhost",
- "udpPort": 6831,
- "maxPacketSize": 65000,
- "sampler": "const",
- "excludePaths": [ "/", "/ping", "/metrics" ]
+ "enabled": true,
+ "serviceName": "orders",
+ "endpoint": "http://localhost:4317",
+ "protocol": "Grpc",
+ "processorType": "Batch",
+ "maxQueueSize": 2048,
+ "scheduledDelayMilliseconds": 5000,
+ "exporterTimeoutMilliseconds": 30000,
+ "maxExportBatchSize": 512
},
"jwt": {
"certificate": {
@@ -231,7 +275,7 @@ Use [**api-workbench**](./api-workbench.rest) inside Visual Studio code with [RE
"enabled": false,
"endpoint": "/metrics"
},
- "mongo": {
+ "mongodb": {
"connectionString": "mongodb://localhost:27017",
"database": "genocs-users-service",
"seed": false
@@ -306,6 +350,11 @@ Use [**api-workbench**](./api-workbench.rest) inside Visual Studio code with [RE
"header": "Certificate"
}
},
+ "azureKeyVault": {
+ "enabled": false,
+ "name": "gnx-keyvault",
+ "managedIdentityId": "secret",
+ },
"vault": {
"enabled": false,
"url": "http://localhost:8200",
@@ -342,7 +391,8 @@ Use [**api-workbench**](./api-workbench.rest) inside Visual Studio code with [RE
## Demo Application
Inside the library there is a simple demo application you can use to test the library.
-Some commands
+Following are the commands to build and run the demo application.
+
``` bash
# Build the solution
dotnet build
@@ -382,13 +432,11 @@ docker build -t genocs/demo-worker:2.0.0 -t genocs/demo-worker:latest -f ./demo-
docker push genocs/demo-worker:2.0.0
docker push genocs/demo-worker:latest
```
-
- ---
+---
## Enterprise Application
-
-Take a look inside **./src/apps** folder. There you can find a full-fledged application composed by:
+Inside **./src/apps** folder you can find a full-fledged application composed by:
- ApiGateway
- Identity Service
- Order Service
@@ -397,7 +445,7 @@ Take a look inside **./src/apps** folder. There you can find a full-fledged appl
In that way you can test the entire flow.
-
+**TODO**: Add a architecture diagram to show the components and how they interact with each other.
### How to BUILD & RUN the application
@@ -463,6 +511,13 @@ You can deploy Demo Application with one click in Heroku, Microsoft Azure, or Go
[
](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fheartexlabs%2Flabel-studio%2Fmaster%2Fazuredeploy.json)
[
](https://deploy.cloud.run)
+## License
+
+This project is licensed with the [MIT license](LICENSE).
+
+## Changelog
+
+View Complete [Changelog](https://github.com/Genocs/microservice-template/blob/main/CHANGELOG.md).
## Community
@@ -470,33 +525,33 @@ You can deploy Demo Application with one click in Heroku, Microsoft Azure, or Go
- Facebook Page [@genocs](https://facebook.com/Genocs)
- Youtube Channel [@genocs](https://youtube.com/c/genocs)
-## Contributors
-Submit your PR and join the list!
+## Support
+
+Has this Project helped you learn something New? or Helped you at work?
+Here are a few ways by which you can support.
+
+- ⭐ Leave a star!
+- 🥇 Recommend this project to your colleagues.
+- 🦸 Do consider endorsing me on LinkedIn for ASP.NET Core - [Connect via LinkedIn](https://www.linkedin.com/in/giovanni-emanuele-nocco-b31a5169/)
+- ☕ If you want to support this project in the long run, [consider buying me a coffee](https://www.buymeacoffee.com/genocs)!
+
-
-
-
+[](https://www.buymeacoffee.com/genocs)
-## License
+## Code Contributors
-This project is licensed with the [MIT license](LICENSE).
+This project exists thanks to all the people who contribute. [Submit your PR and join the team!](CONTRIBUTING.md)
-## Support :star:
+[](https://github.com/genocs/blazor-template/graphs/contributors)
-Has this project helped you learn something New? or Helped you at work?
-Here are a few ways by which you can support.
+## Financial Contributors
-- Leave a star! :star:
-- Recommend this awesome project to your colleagues. 🥇
-- Do consider endorsing me on LinkedIn for ASP.NET Core - [Connect via LinkedIn](https://www.linkedin.com/in/giovanni-emanuele-nocco-b31a5169/) 🦸
-- Or, If you want to support this project in the long run, [consider buying me a coffee](https://www.buymeacoffee.com/genocs)! ☕
+Become a financial contributor and help me sustain the project. [Support the Project!](https://opencollective.com/genocs/contribute)
-
-
-
+
-## **acknowledgments**
+## Acknowledgements
- [devmentors](https://github.com/devmentors)
-- [abp](https://github.com/abpframework)
\ No newline at end of file
+- [abp](https://github.com/abpframework)
diff --git a/assets/buy-me-a-coffee.png b/assets/buy-me-a-coffee.png
new file mode 100644
index 00000000..02687279
Binary files /dev/null and b/assets/buy-me-a-coffee.png differ
diff --git a/assets/genocs-library-logo.png b/assets/genocs-library-logo.png
new file mode 100644
index 00000000..133cb562
Binary files /dev/null and b/assets/genocs-library-logo.png differ
diff --git a/azure-pipeline.yml b/azure/azure-pipeline.yml
similarity index 100%
rename from azure-pipeline.yml
rename to azure/azure-pipeline.yml
diff --git a/azure/infrastructure/helloworld.bicep b/azure/infrastructure/helloworld.bicep
new file mode 100644
index 00000000..3feb8d34
--- /dev/null
+++ b/azure/infrastructure/helloworld.bicep
@@ -0,0 +1,50 @@
+// Get the resource group location
+param location string = 'East US'
+
+@description('The name of you Web Site.')
+param webSiteName string = 'gnx-website'
+
+param uniqueString string = '{uniqueString(resourceGroup().id)}'
+
+// Generate a unique storage account name
+param storageAccountName string = 'helloworldstorage${uniqueString}'
+
+// Create a storage account
+resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
+ name: storageAccountName
+ location: location
+ sku: {
+ name: 'Standard_LRS'
+ }
+ kind: 'StorageV2'
+ properties: {
+ accessTier: 'Hot'
+ }
+}
+
+// Create an App Service Plan
+resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = {
+ name: 'asp-${uniqueString}'
+ location: location
+ sku: {
+ name: 'F1'
+ tier: 'Free'
+ }
+}
+
+// Create a web app
+resource webApp 'Microsoft.Web/sites@2023-12-01' = {
+ name: webSiteName
+ location: location
+ properties: {
+ serverFarmId: appServicePlan.id
+ siteConfig: {
+ appSettings: [
+ {
+ name: 'STORAGE_ACCOUNT_NAME'
+ value: storageAccount.name
+ }
+ ]
+ }
+ }
+}
diff --git a/containers/.env b/containers/.env
new file mode 100644
index 00000000..e69de29b
diff --git a/containers/infrastructure-bare.yml b/containers/infrastructure-bare.yml
index ba8e929a..31e236da 100644
--- a/containers/infrastructure-bare.yml
+++ b/containers/infrastructure-bare.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
rabbitmq:
image: masstransit/rabbitmq
diff --git a/containers/infrastructure-elk.yml b/containers/infrastructure-elk.yml
index d87f8929..3d03dfe6 100644
--- a/containers/infrastructure-elk.yml
+++ b/containers/infrastructure-elk.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.2
diff --git a/containers/infrastructure-ml.yml b/containers/infrastructure-ml.yml
index eba6aa7f..e3f0e21d 100644
--- a/containers/infrastructure-ml.yml
+++ b/containers/infrastructure-ml.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
image_labeling:
image: heartexlabs/label-studio:latest
diff --git a/containers/infrastructure-monitoring.yml b/containers/infrastructure-monitoring.yml
index 6c6b3ab6..6eeedab9 100644
--- a/containers/infrastructure-monitoring.yml
+++ b/containers/infrastructure-monitoring.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
grafana:
image: grafana/grafana
@@ -37,6 +35,7 @@ services:
- 9411:9411
- 14268:14268
- 16686:16686
+ - 4317:4317
# network_mode: host
networks:
- genocs
diff --git a/containers/infrastructure-mysql.yml b/containers/infrastructure-mysql.yml
new file mode 100644
index 00000000..e4dbc650
--- /dev/null
+++ b/containers/infrastructure-mysql.yml
@@ -0,0 +1,23 @@
+services:
+ mysqldb:
+ image: mysql
+ hostname: mysqldb
+ container_name: mysqldb
+ ports:
+ - 3306:3306
+
+ environment:
+ MYSQL_ROOT_PASSWORD: MySect3tPassw!
+ volumes:
+ - mysqlsystem:/var/lib/mysql
+ networks:
+ - genocs
+
+networks:
+ genocs:
+ name: genocs-network
+ external: true
+
+volumes:
+ mysqlsystem:
+ driver: local
diff --git a/containers/infrastructure-oracle.yml b/containers/infrastructure-oracle.yml
new file mode 100644
index 00000000..2ce16a6f
--- /dev/null
+++ b/containers/infrastructure-oracle.yml
@@ -0,0 +1,35 @@
+services:
+ oracledb:
+ image: container-registry.oracle.com/database/express:21.3.0-xe
+ hostname: oracledb
+ container_name: oracledb
+ ports:
+ - 1521:1521
+ - 5500:5500
+
+ environment:
+ ORACLE_PWD: MySect3tPassw!
+ ORACLE_CHARACTERSET: AL32UTF8
+ ENABLE_ARCHIVELOG: true
+ ENABLE_FORCE_LOGGING: true
+
+ volumes:
+ - oracle_data:/opt/oracle/oradata
+ - oracle_startup:/opt/oracle/scripts/startup
+ - oracle_setup:/opt/oracle/scripts/setup
+
+ networks:
+ - genocs
+
+networks:
+ genocs:
+ name: genocs-network
+ external: true
+
+volumes:
+ oracle_data:
+ driver: local
+ oracle_startup:
+ driver: local
+ oracle_setup:
+ driver: local
diff --git a/containers/infrastructure-scaling.yml b/containers/infrastructure-scaling.yml
index a7247e96..99ecf424 100644
--- a/containers/infrastructure-scaling.yml
+++ b/containers/infrastructure-scaling.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
consul:
image: hashicorp/consul
diff --git a/containers/infrastructure-security.yml b/containers/infrastructure-security.yml
index 07f089bf..3ecfd2c5 100644
--- a/containers/infrastructure-security.yml
+++ b/containers/infrastructure-security.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
vault:
image: hashicorp/vault
diff --git a/containers/infrastructure-sqlserver.yml b/containers/infrastructure-sqlserver.yml
index c88354d2..be0d0e94 100644
--- a/containers/infrastructure-sqlserver.yml
+++ b/containers/infrastructure-sqlserver.yml
@@ -1,5 +1,3 @@
-version: "3.9"
-
services:
sqlserver:
diff --git a/demo-docker-compose.yml b/demo-docker-compose.yml
index 2cccfe6b..fb63a465 100644
--- a/demo-docker-compose.yml
+++ b/demo-docker-compose.yml
@@ -1,5 +1,3 @@
-version: '3.9'
-
services:
application.webapi:
image: genocs/demo-webapi:2.0.0
diff --git a/demo-webapi.dockerfile b/demo-webapi.dockerfile
index dea4fa6c..963017d9 100644
--- a/demo-webapi.dockerfile
+++ b/demo-webapi.dockerfile
@@ -1,20 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-
-#FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
-#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
-#FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
-#FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
-FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
-#FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
-#FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build-env
-# FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build-env
-#FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
-FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /src
COPY ["src/Genocs.Core", "src/Genocs.Core/"]
COPY ["src/Genocs.Common", "src/Genocs.Common/"]
diff --git a/demo-worker.dockerfile b/demo-worker.dockerfile
index fa4bd415..dc372871 100644
--- a/demo-worker.dockerfile
+++ b/demo-worker.dockerfile
@@ -1,20 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-
-#FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
-#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
-#FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
-#FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
-FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
-#FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
-#FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build-env
-# FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build-env
-#FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
-FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /src
COPY ["src/Genocs.Core.Demo.Worker", "src/Genocs.Core.Demo.Worker/"]
COPY ["src/Genocs.Core.Demo.Contracts", "src/Genocs.Core.Demo.Contracts/"]
diff --git a/dotnet.ruleset b/dotnet.ruleset
new file mode 100644
index 00000000..3010e47e
--- /dev/null
+++ b/dotnet.ruleset
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/genocs.sln b/genocs.sln
index 38feed0d..16581cec 100644
--- a/genocs.sln
+++ b/genocs.sln
@@ -29,8 +29,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.Core.Demo.Domain", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.Core.Demo.Infrastructure", "src\Genocs.Core.Demo.Infrastructure\Genocs.Core.Demo.Infrastructure.csproj", "{FA01671E-9778-4581-9CD3-4A0651DBC7D7}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.Monitoring", "src\Genocs.Monitoring\Genocs.Monitoring.csproj", "{14F46B52-6C3E-40CC-A18F-1A1E8FA9E6F3}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.QueryBuilder", "src\Genocs.QueryBuilder\Genocs.QueryBuilder.csproj", "{2F9F9EF1-031D-433A-816D-49372AAAAC66}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.QueryBuilder.UnitTests", "src\Genocs.QueryBuilder.UnitTests\Genocs.QueryBuilder.UnitTests.csproj", "{23B5DC61-F78E-42A5-9AA8-AB96DB7C89EC}"
@@ -83,10 +81,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.Common", "src\Genocs
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{51A2E158-4686-4764-91D5-3CDDD06280D4}"
ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
demo-docker-compose.yml = demo-docker-compose.yml
demo-webapi.dockerfile = demo-webapi.dockerfile
demo-worker.dockerfile = demo-worker.dockerfile
+ Directory.Build.props = Directory.Build.props
+ Directory.Build.targets = Directory.Build.targets
+ dotnet.ruleset = dotnet.ruleset
+ global.json = global.json
+ launchSettings.json = launchSettings.json
+ Makefile = Makefile
README.md = README.md
+ stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OrdersService", "OrdersService", "{80862789-8B42-4878-AC10-9CFF06A7313C}"
@@ -121,6 +127,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application"
src\apps\signalr-webapi.dockerfile = src\apps\signalr-webapi.dockerfile
EndProjectSection
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.Secrets.AzureKeyVault", "src\Genocs.Secrets.AzureKeyVault\Genocs.Secrets.AzureKeyVault.csproj", "{ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -171,10 +179,6 @@ Global
{FA01671E-9778-4581-9CD3-4A0651DBC7D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA01671E-9778-4581-9CD3-4A0651DBC7D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA01671E-9778-4581-9CD3-4A0651DBC7D7}.Release|Any CPU.Build.0 = Release|Any CPU
- {14F46B52-6C3E-40CC-A18F-1A1E8FA9E6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {14F46B52-6C3E-40CC-A18F-1A1E8FA9E6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {14F46B52-6C3E-40CC-A18F-1A1E8FA9E6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {14F46B52-6C3E-40CC-A18F-1A1E8FA9E6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{2F9F9EF1-031D-433A-816D-49372AAAAC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F9F9EF1-031D-433A-816D-49372AAAAC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F9F9EF1-031D-433A-816D-49372AAAAC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -287,6 +291,10 @@ Global
{6CE8740F-8561-481B-AC9F-D1E73C449235}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CE8740F-8561-481B-AC9F-D1E73C449235}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CE8740F-8561-481B-AC9F-D1E73C449235}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/global.json b/global.json
new file mode 100644
index 00000000..f6d787e3
--- /dev/null
+++ b/global.json
@@ -0,0 +1,7 @@
+{
+ "sdk": {
+ "version": "8.0.10",
+ "rollForward": "latestMajor",
+ "allowPrerelease": true
+ }
+}
\ No newline at end of file
diff --git a/icon.png b/icon.png
index 66a5cbe2..3f859c6e 100644
Binary files a/icon.png and b/icon.png differ
diff --git a/launchSettings.json b/launchSettings.json
new file mode 100644
index 00000000..c0eaff1c
--- /dev/null
+++ b/launchSettings.json
@@ -0,0 +1,11 @@
+{
+ "profiles": {
+ "Docker Compose": {
+ "commandName": "DockerCompose",
+ "commandVersion": "1.0",
+ "serviceActions": {
+ "genocs.demo.webapi": "StartDebugging"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Genocs.Auth/AccessTokenValidatorMiddleware.cs b/src/Genocs.Auth/AccessTokenValidatorMiddleware.cs
index 94c54a7b..b0de9341 100644
--- a/src/Genocs.Auth/AccessTokenValidatorMiddleware.cs
+++ b/src/Genocs.Auth/AccessTokenValidatorMiddleware.cs
@@ -1,11 +1,11 @@
+using Genocs.Auth.Configurations;
using Microsoft.AspNetCore.Http;
using System.Net;
namespace Genocs.Auth;
-
///
-/// The access token validator middleware
+/// The access token validator middleware.
///
public class AccessTokenValidatorMiddleware : IMiddleware
{
@@ -13,10 +13,10 @@ public class AccessTokenValidatorMiddleware : IMiddleware
private readonly IEnumerable _endpoints;
///
- /// The AccessTokenValidatorMiddleware constructor
+ /// The AccessTokenValidatorMiddleware constructor.
///
- /// The access token service
- /// The options
+ /// The access token service.
+ /// The options.
public AccessTokenValidatorMiddleware(IAccessTokenService accessTokenService, JwtOptions options)
{
_accessTokenService = accessTokenService;
@@ -24,14 +24,15 @@ public AccessTokenValidatorMiddleware(IAccessTokenService accessTokenService, Jw
}
///
- /// The InvokeAsync method
+ /// The InvokeAsync method.
///
- /// The http context
- /// The request delegate
+ /// The http context.
+ /// The request delegate.
///
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
- var path = context.Request.Path.HasValue ? context.Request.Path.Value : string.Empty;
+ string path = context.Request.Path.HasValue ? context.Request.Path.Value : string.Empty;
+
if (_endpoints.Contains(path))
{
await next(context);
diff --git a/src/Genocs.Auth/AuthAttribute.cs b/src/Genocs.Auth/AuthAttribute.cs
index 4188f8bd..31c613c5 100644
--- a/src/Genocs.Auth/AuthAttribute.cs
+++ b/src/Genocs.Auth/AuthAttribute.cs
@@ -3,16 +3,17 @@
namespace Genocs.Auth;
///
-/// The authorization Attribute
+/// The authorization Attribute.
///
public class AuthAttribute : AuthorizeAttribute
{
///
- /// The AuthAttribute constructor
+ /// The AuthAttribute constructor.
///
- /// The authorization schema
- /// The authorization policy
- public AuthAttribute(string scheme, string policy = "") : base(policy)
+ /// The authorization schema.
+ /// The authorization policy.
+ public AuthAttribute(string scheme, string policy = "")
+ : base(policy)
{
AuthenticationSchemes = scheme;
}
diff --git a/src/Genocs.Auth/Builders/JwtOptionsBuilder.cs b/src/Genocs.Auth/Builders/JwtOptionsBuilder.cs
index 0ab9ce28..c81ab262 100644
--- a/src/Genocs.Auth/Builders/JwtOptionsBuilder.cs
+++ b/src/Genocs.Auth/Builders/JwtOptionsBuilder.cs
@@ -1,3 +1,5 @@
+using Genocs.Auth.Configurations;
+
namespace Genocs.Auth.Builders;
internal sealed class JwtOptionsBuilder : IJwtOptionsBuilder
diff --git a/src/Genocs.Auth/IJwtOptionsBuilder.cs b/src/Genocs.Auth/Configurations/IJwtOptionsBuilder.cs
similarity index 92%
rename from src/Genocs.Auth/IJwtOptionsBuilder.cs
rename to src/Genocs.Auth/Configurations/IJwtOptionsBuilder.cs
index 49e358f5..9675c881 100644
--- a/src/Genocs.Auth/IJwtOptionsBuilder.cs
+++ b/src/Genocs.Auth/Configurations/IJwtOptionsBuilder.cs
@@ -1,4 +1,4 @@
-namespace Genocs.Auth;
+namespace Genocs.Auth.Configurations;
public interface IJwtOptionsBuilder
{
diff --git a/src/Genocs.Auth/Configurations/JwtOptions.cs b/src/Genocs.Auth/Configurations/JwtOptions.cs
new file mode 100644
index 00000000..79566a5c
--- /dev/null
+++ b/src/Genocs.Auth/Configurations/JwtOptions.cs
@@ -0,0 +1,83 @@
+namespace Genocs.Auth.Configurations;
+
+public class JwtOptions
+{
+ ///
+ /// Default section name.
+ ///
+ public const string Position = "jwt";
+
+ ///
+ /// It defines whether the section is enabled or not.
+ ///
+ public bool Enabled { get; set; }
+
+ public IEnumerable? AllowAnonymousEndpoints { get; set; }
+ public CertificateOptions? Certificate { get; set; }
+ public string? Algorithm { get; set; }
+ public string? Issuer { get; set; }
+ public string? IssuerSigningKey { get; set; }
+ public string? Authority { get; set; }
+ public string? Audience { get; set; }
+
+ ///
+ /// This is the Authentication Scheme name.
+ ///
+ public string Challenge { get; set; } = "Bearer";
+ public string MetadataAddress { get; set; } = "/.well-known/openid-configuration";
+ public bool SaveToken { get; set; } = true;
+ public bool SaveSigninToken { get; set; }
+ public bool RequireAudience { get; set; } = true;
+ public bool RequireHttpsMetadata { get; set; }
+ public bool RequireExpirationTime { get; set; } = true;
+ public bool RequireSignedTokens { get; set; } = true;
+ public int ExpiryMinutes { get; set; }
+ public TimeSpan? Expiry { get; set; }
+ public string? ValidAudience { get; set; }
+ public IEnumerable? ValidAudiences { get; set; }
+ public string? ValidIssuer { get; set; }
+ public IEnumerable? ValidIssuers { get; set; }
+ public bool ValidateActor { get; set; }
+
+ ///
+ /// It defines whether the audience should be validated.
+ /// Defaults to true.
+ ///
+ public bool ValidateAudience { get; set; } = true;
+
+ ///
+ /// It defines whether the issuer should be validated.
+ /// Defaults to true.
+ ///
+ public bool ValidateIssuer { get; set; } = true;
+ public bool ValidateLifetime { get; set; } = true;
+ public bool ValidateTokenReplay { get; set; }
+ public bool ValidateIssuerSigningKey { get; set; }
+
+ ///
+ /// It defines whether the token should be refreshed when the issuer key is not found.
+ /// Defaults to true.
+ ///
+ public bool RefreshOnIssuerKeyNotFound { get; set; } = true;
+
+ ///
+ /// It defines whether the error details should be included in the response.
+ /// Defaults to true.
+ ///
+ public bool IncludeErrorDetails { get; set; } = true;
+ public string? AuthenticationType { get; set; }
+ public string? NameClaimType { get; set; }
+
+ ///
+ /// The claim type that will be used to determine the user's roles.
+ /// Defaults to "Role".
+ ///
+ public string RoleClaimType { get; set; } = "Role";
+
+ public class CertificateOptions
+ {
+ public string? Location { get; set; }
+ public string? RawData { get; set; }
+ public string? Password { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Genocs.Auth/DisabledAuthenticationPolicyEvaluator.cs b/src/Genocs.Auth/DisabledAuthenticationPolicyEvaluator.cs
index 9723b386..85cc1ab8 100644
--- a/src/Genocs.Auth/DisabledAuthenticationPolicyEvaluator.cs
+++ b/src/Genocs.Auth/DisabledAuthenticationPolicyEvaluator.cs
@@ -17,8 +17,11 @@ internal sealed class DisabledAuthenticationPolicyEvaluator : IPolicyEvaluator
///
public Task AuthenticateAsync(AuthorizationPolicy policy, HttpContext context)
{
- var authenticationTicket = new AuthenticationTicket(new ClaimsPrincipal(),
- new AuthenticationProperties(), JwtBearerDefaults.AuthenticationScheme);
+ var authenticationTicket = new AuthenticationTicket(
+ new ClaimsPrincipal(),
+ new AuthenticationProperties(),
+ JwtBearerDefaults.AuthenticationScheme);
+
return Task.FromResult(AuthenticateResult.Success(authenticationTicket));
}
@@ -30,8 +33,11 @@ public Task AuthenticateAsync(AuthorizationPolicy policy, Ht
///
///
///
- public Task AuthorizeAsync(AuthorizationPolicy policy,
- AuthenticateResult authenticationResult, HttpContext context, object resource)
+ public Task AuthorizeAsync(
+ AuthorizationPolicy policy,
+ AuthenticateResult authenticationResult,
+ HttpContext context,
+ object resource)
{
return Task.FromResult(PolicyAuthorizationResult.Success());
}
diff --git a/src/Genocs.Auth/Extensions.cs b/src/Genocs.Auth/Extensions.cs
index eaeb7a6e..05e93b9f 100644
--- a/src/Genocs.Auth/Extensions.cs
+++ b/src/Genocs.Auth/Extensions.cs
@@ -1,11 +1,15 @@
+using Genocs.Auth.Configurations;
using Genocs.Auth.Handlers;
using Genocs.Auth.Services;
using Genocs.Core.Builders;
+using Genocs.Security.Services;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.IdentityModel.Protocols;
+using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.Text;
@@ -14,23 +18,26 @@ namespace Genocs.Auth;
public static class Extensions
{
- private const string SectionName = "jwt";
private const string RegistryName = "auth";
- public static IGenocsBuilder AddJwt(this IGenocsBuilder builder, string sectionName = SectionName,
- Action? optionsFactory = null)
+ public static IGenocsBuilder AddJwt(
+ this IGenocsBuilder builder,
+ string sectionName = JwtOptions.Position,
+ Action? optionsFactory = null)
{
if (string.IsNullOrWhiteSpace(sectionName))
{
- sectionName = SectionName;
+ sectionName = JwtOptions.Position;
}
var options = builder.GetOptions(sectionName);
return builder.AddJwt(options, optionsFactory);
}
- private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions options,
- Action? optionsFactory = null)
+ private static IGenocsBuilder AddJwt(
+ this IGenocsBuilder builder,
+ JwtOptions options,
+ Action? optionsFactory = null)
{
if (!builder.TryRegister(RegistryName))
{
@@ -42,7 +49,7 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
builder.Services.AddSingleton();
builder.Services.AddTransient();
- if (options.AuthenticationDisabled)
+ if (!options.Enabled)
{
builder.Services.AddSingleton();
}
@@ -63,6 +70,7 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
SaveSigninToken = options.SaveSigninToken,
RequireExpirationTime = options.RequireExpirationTime,
RequireSignedTokens = options.RequireSignedTokens,
+ RoleClaimType = options.RoleClaimType,
ClockSkew = TimeSpan.Zero
};
@@ -71,28 +79,28 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
tokenValidationParameters.AuthenticationType = options.AuthenticationType;
}
- var hasCertificate = false;
+ bool hasCertificate = false;
if (options.Certificate is not null)
{
- X509Certificate2 certificate = null;
- var password = options.Certificate.Password;
- var hasPassword = !string.IsNullOrWhiteSpace(password);
+ X509Certificate2? certificate = null;
+ string? password = options.Certificate.Password;
+ bool hasPassword = !string.IsNullOrWhiteSpace(password);
if (!string.IsNullOrWhiteSpace(options.Certificate.Location))
{
certificate = hasPassword
? new X509Certificate2(options.Certificate.Location, password)
: new X509Certificate2(options.Certificate.Location);
- var keyType = certificate.HasPrivateKey ? "with private key" : "with public key only";
+ string keyType = certificate.HasPrivateKey ? "with private key" : "with public key only";
Console.WriteLine($"Loaded X.509 certificate from location: '{options.Certificate.Location}' {keyType}.");
}
if (!string.IsNullOrWhiteSpace(options.Certificate.RawData))
{
- var rawData = Convert.FromBase64String(options.Certificate.RawData);
+ byte[] rawData = Convert.FromBase64String(options.Certificate.RawData);
certificate = hasPassword
? new X509Certificate2(rawData, password)
: new X509Certificate2(rawData);
- var keyType = certificate.HasPrivateKey ? "with private key" : "with public key only";
+ string keyType = certificate.HasPrivateKey ? "with private key" : "with public key only";
Console.WriteLine($"Loaded X.509 certificate from raw data {keyType}.");
}
@@ -105,11 +113,12 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
hasCertificate = true;
tokenValidationParameters.IssuerSigningKey = new X509SecurityKey(certificate);
- var actionType = certificate.HasPrivateKey ? "issuing" : "validating";
+ string actionType = certificate.HasPrivateKey ? "issuing" : "validating";
Console.WriteLine($"Using X.509 certificate for {actionType} tokens.");
}
}
+ // If no certificate is provided, use symmetric encryption.
if (!string.IsNullOrWhiteSpace(options.IssuerSigningKey) && !hasCertificate)
{
if (string.IsNullOrWhiteSpace(options.Algorithm) || hasCertificate)
@@ -117,7 +126,7 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
options.Algorithm = SecurityAlgorithms.HmacSha256;
}
- var rawKey = Encoding.UTF8.GetBytes(options.IssuerSigningKey);
+ byte[] rawKey = Encoding.UTF8.GetBytes(options.IssuerSigningKey);
tokenValidationParameters.IssuerSigningKey = new SymmetricSecurityKey(rawKey);
Console.WriteLine("Using symmetric encryption for issuing tokens.");
}
@@ -135,8 +144,9 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
builder.Services
.AddAuthentication(o =>
{
- o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
- o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
+ o.DefaultAuthenticateScheme = options.Challenge;
+ o.DefaultChallengeScheme = options.Challenge;
+ o.DefaultScheme = options.Challenge;
})
.AddJwtBearer(o =>
{
@@ -162,17 +172,102 @@ private static IGenocsBuilder AddJwt(this IGenocsBuilder builder, JwtOptions opt
return builder;
}
+ ///
+ /// Enable OpenId Connect Authentication.
+ /// It can be used with Firebase Authentication.
+ ///
+ /// The Genocs builder.
+ /// The configuration section name.
+ /// The Genocs builder you can use for chain.
+ public static IGenocsBuilder AddOpenIdJwt(
+ this IGenocsBuilder builder,
+ string sectionName = JwtOptions.Position)
+ {
+
+ JwtOptions options = builder.Configuration.GetOptions(sectionName);
+
+ string metadataAddress = $"{options.Issuer}{options.MetadataAddress}";
+ var configurationManager = new ConfigurationManager(metadataAddress, new OpenIdConnectConfigurationRetriever());
+
+ builder.Services
+ .AddAuthentication(o =>
+ {
+ o.DefaultAuthenticateScheme = options.Challenge;
+ o.DefaultChallengeScheme = options.Challenge;
+ o.DefaultScheme = options.Challenge;
+ })
+ .AddJwtBearer(o =>
+ {
+ o.IncludeErrorDetails = options.IncludeErrorDetails;
+ o.RefreshOnIssuerKeyNotFound = options.RefreshOnIssuerKeyNotFound;
+ o.MetadataAddress = metadataAddress;
+ o.ConfigurationManager = configurationManager;
+ o.Audience = options.Audience;
+ });
+
+ return builder;
+ }
+
+ ///
+ /// It adds the private key JWT authentication.
+ ///
+ /// The Genocs builder.
+ /// The optional section name. Default name: 'jwt'.
+ /// The Genocs builder you can use for chaining.
+ /// Whenever mandatory data like 'IssuerSigningKey' is missing.
+ public static IGenocsBuilder AddPrivateKeyJwt(
+ this IGenocsBuilder builder,
+ string sectionName = JwtOptions.Position)
+ {
+ if (string.IsNullOrWhiteSpace(sectionName))
+ {
+ sectionName = JwtOptions.Position;
+ }
+
+ JwtOptions options = builder.Configuration.GetOptions(sectionName);
+
+ if (string.IsNullOrWhiteSpace(options.IssuerSigningKey))
+ {
+ throw new InvalidOperationException("Issuer signing key is missing.");
+ }
+
+ SecurityKey signingKey = SecurityKeyBuilder.CreateRsaSecurityKey(options.IssuerSigningKey);
+
+ builder.Services
+ .AddAuthentication(o =>
+ {
+ o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
+ })
+ .AddJwtBearer(o =>
+ {
+ o.SaveToken = options.SaveToken;
+ o.RequireHttpsMetadata = options.RequireHttpsMetadata;
+ o.TokenValidationParameters = new TokenValidationParameters()
+ {
+ IssuerSigningKey = signingKey,
+ ValidateAudience = options.ValidateAudience,
+ ValidAudience = options.ValidAudience,
+ ValidateIssuer = options.ValidateIssuer,
+ ValidIssuer = options.ValidIssuer,
+ ValidateLifetime = options.ValidateLifetime,
+ ValidateIssuerSigningKey = options.ValidateIssuerSigningKey
+ };
+ });
+
+ return builder;
+ }
+
public static IApplicationBuilder UseAccessTokenValidator(this IApplicationBuilder app)
=> app.UseMiddleware();
}
///
-/// DateExtensions extension method
+/// DateExtensions extension method.
///
internal static class DateExtensions
{
///
- /// ToTimestamp support function
+ /// ToTimestamp support function.
///
///
///
diff --git a/src/Genocs.Auth/Genocs.Auth.csproj b/src/Genocs.Auth/Genocs.Auth.csproj
index 8b9b60a8..924792ef 100644
--- a/src/Genocs.Auth/Genocs.Auth.csproj
+++ b/src/Genocs.Auth/Genocs.Auth.csproj
@@ -1,67 +1,45 @@
-
- net6.0;net7.0
- enable
- enable
- Genocs.Auth
- 10.0
- true
- 5.0.0-preview.4.0
- 5.0.0
- Nocco Giovanni Emanuele
- Genocs
- The authorization library useful to build .NET Core projects.
- The authorization library useful to build .NET Core projects.
- Genocs 2023
- LICENSE
- https://github.com/Genocs/genocs-library
- https://github.com/Genocs/genocs-library.git
- icon.png
- git
- aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles
- README.md
- Aligned to the ecosystem
- True
- latest
- True
-
-
-
-
- True
- \
-
-
- True
- \
-
-
- True
- \
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ net8.0;net7.0;net6.0
+ Genocs.Auth
+ Genocs.Auth
+ Genocs.Auth
+ The authorization library useful to build .NET Core projects.
+ The authorization library useful to build .NET Core projects.
+ true
+ 5.0.0
+ Nocco Giovanni Emanuele
+ microservice microservices solid solid-principles authentication genocs
+ README_NUGET.md
+ Aligned to the ecosystem
+ True
+ latest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Genocs.Auth/Handlers/JwtHandler.cs b/src/Genocs.Auth/Handlers/JwtHandler.cs
index 2af2b6bc..36e197e0 100644
--- a/src/Genocs.Auth/Handlers/JwtHandler.cs
+++ b/src/Genocs.Auth/Handlers/JwtHandler.cs
@@ -1,3 +1,4 @@
+using Genocs.Auth.Configurations;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
@@ -22,7 +23,7 @@ internal sealed class JwtHandler : IJwtHandler
private readonly JwtOptions _options;
private readonly TokenValidationParameters _tokenValidationParameters;
private readonly SigningCredentials _signingCredentials;
- private readonly string _issuer;
+ private readonly string? _issuer;
public JwtHandler(JwtOptions options, TokenValidationParameters tokenValidationParameters)
{
@@ -43,7 +44,17 @@ public JwtHandler(JwtOptions options, TokenValidationParameters tokenValidationP
_issuer = options.Issuer;
}
- public JsonWebToken CreateToken(string userId,
+ ///
+ /// Creates a new token.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// It is thrown when mandatory data is empty.
+ public JsonWebToken CreateToken(
+ string userId,
string? role = null,
string? audience = null,
IDictionary>? claims = null)
@@ -61,6 +72,7 @@ public JsonWebToken CreateToken(string userId,
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
new(JwtRegisteredClaimNames.Iat, now.ToTimestamp().ToString()),
};
+
if (!string.IsNullOrWhiteSpace(role))
{
jwtClaims.Add(new Claim(ClaimTypes.Role, role));
@@ -91,10 +103,9 @@ public JsonWebToken CreateToken(string userId,
claims: jwtClaims,
notBefore: now,
expires: expires,
- signingCredentials: _signingCredentials
- );
+ signingCredentials: _signingCredentials);
- var token = new JwtSecurityTokenHandler().WriteToken(jwt);
+ string token = new JwtSecurityTokenHandler().WriteToken(jwt);
return new JsonWebToken
{
@@ -114,8 +125,11 @@ public JsonWebToken CreateToken(string userId,
///
public JsonWebTokenPayload? GetTokenPayload(string accessToken)
{
- _jwtSecurityTokenHandler.ValidateToken(accessToken, _tokenValidationParameters,
- out var validatedSecurityToken);
+ _jwtSecurityTokenHandler.ValidateToken(
+ accessToken,
+ _tokenValidationParameters,
+ out var validatedSecurityToken);
+
if (validatedSecurityToken is not JwtSecurityToken jwt)
{
return null;
diff --git a/src/Genocs.Auth/IJwtHandler.cs b/src/Genocs.Auth/IJwtHandler.cs
index 45f3706a..5720e6fa 100644
--- a/src/Genocs.Auth/IJwtHandler.cs
+++ b/src/Genocs.Auth/IJwtHandler.cs
@@ -1,27 +1,28 @@
namespace Genocs.Auth;
///
-/// IJwtHandler interface definition
+/// IJwtHandler interface definition.
///
public interface IJwtHandler
{
///
- /// It allows to create a new JsonWebToken
+ /// It allows to create a new JsonWebToken.
///
- /// The userId
- /// The role
- /// The audience
- /// The claims
- /// The JsonWebToken just created
- JsonWebToken CreateToken(string userId,
- string? role = null,
- string? audience = null,
- IDictionary>? claims = null);
+ /// The userId.
+ /// The role.
+ /// The audience.
+ /// The claims.
+ /// The JsonWebToken just created.
+ JsonWebToken CreateToken(
+ string userId,
+ string? role = null,
+ string? audience = null,
+ IDictionary>? claims = null);
///
- /// Get the JsonWebTokenPayload from the accessToken
+ /// Get the JsonWebTokenPayload from the accessToken.
///
- /// The access token string value
- /// The JsonWebTokenPayload
+ /// The access token string value.
+ /// The JsonWebTokenPayload.
JsonWebTokenPayload? GetTokenPayload(string accessToken);
}
\ No newline at end of file
diff --git a/src/Genocs.Auth/JsonWebToken.cs b/src/Genocs.Auth/JsonWebToken.cs
index 6a3a6b66..bdf2eefc 100644
--- a/src/Genocs.Auth/JsonWebToken.cs
+++ b/src/Genocs.Auth/JsonWebToken.cs
@@ -1,6 +1,5 @@
namespace Genocs.Auth;
-
///
/// The JSON Web Token definition.
///
@@ -15,7 +14,7 @@ public class JsonWebToken
/// Gets or sets the refresh token.
///
public string? RefreshToken { get; set; }
-
+
///
/// Gets or sets the access token expiration.
///
@@ -34,5 +33,5 @@ public class JsonWebToken
///
/// The claims.
///
- public IDictionary>? Claims { get; set; }
+ public IDictionary>? Claims { get; set; }
}
\ No newline at end of file
diff --git a/src/Genocs.Auth/JsonWebTokenPayload.cs b/src/Genocs.Auth/JsonWebTokenPayload.cs
index 68dfe0f4..b3dcfdc1 100644
--- a/src/Genocs.Auth/JsonWebTokenPayload.cs
+++ b/src/Genocs.Auth/JsonWebTokenPayload.cs
@@ -1,27 +1,27 @@
namespace Genocs.Auth;
///
-/// The JsonWebToken payload
+/// The JsonWebToken payload.
///
public class JsonWebTokenPayload
{
///
- /// The subject
+ /// The subject.
///
public string? Subject { get; set; }
///
- /// The Identity Role
+ /// The Identity Role.
///
public string? Role { get; set; }
///
- /// The expiration ticks
+ /// The expiration ticks.
///
public long Expires { get; set; }
///
- /// List of claims
+ /// List of claims.
///
public IDictionary>? Claims { get; set; }
}
\ No newline at end of file
diff --git a/src/Genocs.Auth/JwtAuthAttribute.cs b/src/Genocs.Auth/JwtAuthAttribute.cs
index c3b4715e..96439a83 100644
--- a/src/Genocs.Auth/JwtAuthAttribute.cs
+++ b/src/Genocs.Auth/JwtAuthAttribute.cs
@@ -4,7 +4,8 @@ public class JwtAuthAttribute : AuthAttribute
{
public const string AuthenticationScheme = "Bearer";
- public JwtAuthAttribute(string policy = "") : base(AuthenticationScheme, policy)
+ public JwtAuthAttribute(string policy = "")
+ : base(AuthenticationScheme, policy)
{
}
}
\ No newline at end of file
diff --git a/src/Genocs.Auth/JwtOptions.cs b/src/Genocs.Auth/JwtOptions.cs
deleted file mode 100644
index b3f2aaf4..00000000
--- a/src/Genocs.Auth/JwtOptions.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace Genocs.Auth;
-
-public class JwtOptions
-{
- public bool AuthenticationDisabled { get; set; }
- public IEnumerable AllowAnonymousEndpoints { get; set; }
- public CertificateOptions Certificate { get; set; }
- public string Algorithm { get; set; }
- public string Issuer { get; set; }
- public string IssuerSigningKey { get; set; }
- public string Authority { get; set; }
- public string Audience { get; set; }
- public string Challenge { get; set; } = "Bearer";
- public string MetadataAddress { get; set; }
- public bool SaveToken { get; set; } = true;
- public bool SaveSigninToken { get; set; }
- public bool RequireAudience { get; set; } = true;
- public bool RequireHttpsMetadata { get; set; } = true;
- public bool RequireExpirationTime { get; set; } = true;
- public bool RequireSignedTokens { get; set; } = true;
- public int ExpiryMinutes { get; set; }
- public TimeSpan? Expiry { get; set; }
- public string ValidAudience { get; set; }
- public IEnumerable ValidAudiences { get; set; }
- public string ValidIssuer { get; set; }
- public IEnumerable ValidIssuers { get; set; }
- public bool ValidateActor { get; set; }
- public bool ValidateAudience { get; set; } = true;
- public bool ValidateIssuer { get; set; } = true;
- public bool ValidateLifetime { get; set; } = true;
- public bool ValidateTokenReplay { get; set; }
- public bool ValidateIssuerSigningKey { get; set; }
- public bool RefreshOnIssuerKeyNotFound { get; set; } = true;
- public bool IncludeErrorDetails { get; set; } = true;
- public string AuthenticationType { get; set; }
- public string NameClaimType { get; set; }
- public string RoleClaimType { get; set; }
-
- public class CertificateOptions
- {
- public string Location { get; set; }
- public string RawData { get; set; }
- public string Password { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Genocs.Auth/README.md b/src/Genocs.Auth/README_NUGET.md
similarity index 65%
rename from src/Genocs.Auth/README.md
rename to src/Genocs.Auth/README_NUGET.md
index a840446a..86096c0e 100644
--- a/src/Genocs.Auth/README.md
+++ b/src/Genocs.Auth/README_NUGET.md
@@ -3,7 +3,7 @@
This package contains a set of functionalities to handling authorization logic as JWT.
First of all I have to say thanks to devmentors.
-The libraries are built using .NET7.
+The libraries are built using net8, net7, net6.
## Description
@@ -37,7 +37,39 @@ Following are the project settings needed to enable monitoring
## Release notes
-### [2023-03-12] 5.0.0-preview.5.0
+### [2024-06-15] 6.0.0
+- Added support for Azure Key Vault
+- Unified settings
+
+### [2024-01-23] 5.0.6
+- Refactory Settings
+- Updated nuget packages
+
+### [2023-11-25] 5.0.5
+- Moved to NET8
+
+### [yyyy-mm-dd] 5.0.4
+-
+
+### [yyyy-mm-dd] 5.0.3
+-
+
+### [yyyy-mm-dd] 5.0.2
+-
+
+### [yyyy-mm-dd] 5.0.1
+-
+
+### [2023-11-25] 5.0.0
+- Moved to NET8
+
+### [2023-10-13] 5.0.0-preview.5.0
+- Added [editorconfig](https://editorconfig.org/)
+- Added StyleCop
+- Updated logo
+- Updated readme
+
+### [2023-03-12] 5.0.0-preview.4.0
- Implemented MongoDB repository interfaces
### [2023-03-24] 5.0.0
diff --git a/src/Genocs.Auth/Services/InMemoryAccessTokenService.cs b/src/Genocs.Auth/Services/InMemoryAccessTokenService.cs
index 5540ba21..8ce4fb58 100644
--- a/src/Genocs.Auth/Services/InMemoryAccessTokenService.cs
+++ b/src/Genocs.Auth/Services/InMemoryAccessTokenService.cs
@@ -1,3 +1,4 @@
+using Genocs.Auth.Configurations;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Primitives;
@@ -10,9 +11,10 @@ internal sealed class InMemoryAccessTokenService : IAccessTokenService
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly TimeSpan _expires;
- public InMemoryAccessTokenService(IMemoryCache cache,
- IHttpContextAccessor httpContextAccessor,
- JwtOptions jwtOptions)
+ public InMemoryAccessTokenService(
+ IMemoryCache cache,
+ IHttpContextAccessor httpContextAccessor,
+ JwtOptions jwtOptions)
{
_cache = cache;
_httpContextAccessor = httpContextAccessor;
diff --git a/src/Genocs.Common/Options/AppSettings.cs b/src/Genocs.Common/Configurations/AppOptions.cs
similarity index 58%
rename from src/Genocs.Common/Options/AppSettings.cs
rename to src/Genocs.Common/Configurations/AppOptions.cs
index 014b578f..79dd7851 100644
--- a/src/Genocs.Common/Options/AppSettings.cs
+++ b/src/Genocs.Common/Configurations/AppOptions.cs
@@ -1,42 +1,47 @@
-namespace Genocs.Common.Options;
+namespace Genocs.Common.Configurations;
///
-/// The application settings
+/// The application settings.
///
-public class AppSettings
+public class AppOptions
{
///
- /// Default section name
+ /// Default section name.
///
- public const string Position = "App";
+ public const string Position = "app";
///
- /// Application name
+ /// It defines whether the section is enabled or not.
+ ///
+ public bool Enabled { get; set; }
+
+ ///
+ /// Application name.
///
public string? Name { get; set; }
///
- /// Service name
+ /// Service name.
///
public string? Service { get; set; }
///
- /// The instance of the service
+ /// The instance of the service.
///
public string? Instance { get; set; }
///
- /// The application version
+ /// The application version.
///
public string? Version { get; set; }
///
- /// It defines whether the banner is shown into the console at startup time or not
+ /// It defines whether the banner is shown into the console at startup time or not.
///
public bool DisplayBanner { get; set; }
///
- /// It defines whether the application version is shown into the console at startup time or not
+ /// It defines whether the application version is shown into the console at startup time or not.
///
public bool DisplayVersion { get; set; }
}
\ No newline at end of file
diff --git a/src/Genocs.Common/Genocs.Common.csproj b/src/Genocs.Common/Genocs.Common.csproj
index a118ec23..2ade0ec7 100644
--- a/src/Genocs.Common/Genocs.Common.csproj
+++ b/src/Genocs.Common/Genocs.Common.csproj
@@ -1,45 +1,20 @@
-
+
-
- netstandard2.1
- enable
- enable
- Genocs.Common
- 10.0
- true
- 5.0.0-preview.4.0
- 5.0.0
- Nocco Giovanni Emanuele
- Genocs
- The commons components library useful to build .NET Core projects.
- The commons components library useful to build .NET Core projects.
- Genocs 2023
- LICENSE
- https://github.com/Genocs/genocs-library
- https://github.com/Genocs/genocs-library.git
- icon.png
- git
- aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles
- README.md
- Aligned to the ecosystem
- True
- latest
- True
-
-
-
-
- True
- \
-
-
- True
- \
-
-
- True
- \
-
-
+
+ net8.0;net7.0;net6.0
+ Genocs.Common
+ Genocs.Common
+ Genocs.Common
+ The Genocs Library - Common components.
+ The common components to build .NET Core projects along with Genocs Library.
+ true
+ 5.0.0
+ Nocco Giovanni Emanuele
+ microservice microservices solid solid-principles genocs
+ README_NUGET.md
+ Aligned to the ecosystem
+ True
+ latest
+
diff --git a/src/Genocs.Common/README.md b/src/Genocs.Common/README_NUGET.md
similarity index 56%
rename from src/Genocs.Common/README.md
rename to src/Genocs.Common/README_NUGET.md
index 36aac719..ddab0eb4 100644
--- a/src/Genocs.Common/README.md
+++ b/src/Genocs.Common/README_NUGET.md
@@ -15,17 +15,5 @@ Please check the GitHub repository getting more info.
## Release notes
-### [2023-03-12] 5.0.0-preview.5.0
-- Implemented MongoDB repository interfaces
+Release notes can be found in the [CHANGELOG](https://github.com/Genocs/genocs-library/blob/b98629b4001aad7a2123190cfd4cc63ae7b6f292/CHANGELOG.md) file.
-### [2023-03-24] 5.0.0
-- New Architecture
-
-### [2023-03-12] 3.1.0
-- Added Builders
-
-### [2023-03-12] 3.0.0
-- Refactory to implement CQRS pattern
-
-### [2023-03-04] 2.4.1
-- Updated System.Text.Json
\ No newline at end of file
diff --git a/src/Genocs.Common/Types/DecoratorAttribute.cs b/src/Genocs.Common/Types/DecoratorAttribute.cs
index 07794b3e..fdfba28b 100644
--- a/src/Genocs.Common/Types/DecoratorAttribute.cs
+++ b/src/Genocs.Common/Types/DecoratorAttribute.cs
@@ -1,8 +1,9 @@
namespace Genocs.Common.Types;
///
-/// DecoratorAttribute placeholder
+/// DecoratorAttribute placeholder.
///
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public class DecoratorAttribute : Attribute
{
}
\ No newline at end of file
diff --git a/src/Genocs.Common/Types/Extensions.cs b/src/Genocs.Common/Types/Extensions.cs
index ba2548ed..485790dd 100644
--- a/src/Genocs.Common/Types/Extensions.cs
+++ b/src/Genocs.Common/Types/Extensions.cs
@@ -5,12 +5,12 @@
namespace Genocs.Common.Types;
///
-/// Type extensions
+/// Type extensions.
///
public static class Extensions
{
///
- /// GetDefaultInstance
+ /// GetDefaultInstance.
///
///
///
@@ -21,9 +21,9 @@ public static class Extensions
return string.Empty;
}
- var defaultValueCache = new Dictionary();
+ var defaultValueCache = new Dictionary();
- if (TryGetDefaultValue(type, out var instance, defaultValueCache))
+ if (TryGetDefaultValue(type, out object? instance, defaultValueCache))
{
return instance;
}
@@ -32,17 +32,17 @@ public static class Extensions
}
public static object SetDefaultInstanceProperties(this object instance)
- => SetDefaultInstanceProperties(instance, new Dictionary());
+ => SetDefaultInstanceProperties(instance, new Dictionary());
- private static object SetDefaultInstanceProperties(object instance, Dictionary defaultValueCache)
+ private static object SetDefaultInstanceProperties(object instance, Dictionary defaultValueCache)
{
- defaultValueCache ??= new Dictionary();
+ defaultValueCache ??= new Dictionary();
var type = instance.GetType();
foreach (var propertyInfo in type.GetProperties(BindingFlags.Instance))
{
- if (TryGetDefaultValue(propertyInfo.PropertyType, out var defaultValue, defaultValueCache))
+ if (TryGetDefaultValue(propertyInfo.PropertyType, out object? defaultValue, defaultValueCache))
{
SetValue(propertyInfo, instance, defaultValue);
}
@@ -51,7 +51,7 @@ private static object SetDefaultInstanceProperties(object instance, Dictionary defaultValueCache)
+ private static bool TryGetDefaultValue(Type type, out object? defaultValue, Dictionary defaultValueCache)
{
if (defaultValueCache.TryGetValue(type, out defaultValue))
{
@@ -116,6 +116,7 @@ private static bool TryGetDefaultValue(Type type, out object? defaultValue, Dict
return false;
}
+ // TODO: Refactor this to remove the use of FormatterServices
defaultValue = FormatterServices.GetUninitializedObject(type);
defaultValueCache[type] = defaultValue;
@@ -158,7 +159,7 @@ private static bool TryGetCollectionDefaultValue(Type type, out object? defaultV
return true;
}
- private static void SetValue(PropertyInfo propertyInfo, object instance, object value)
+ private static void SetValue(PropertyInfo propertyInfo, object instance, object? value)
{
if (propertyInfo.CanWrite)
{
diff --git a/src/Genocs.Common/Types/HiddenAttribute.cs b/src/Genocs.Common/Types/HiddenAttribute.cs
index 70d846fb..69480b4f 100644
--- a/src/Genocs.Common/Types/HiddenAttribute.cs
+++ b/src/Genocs.Common/Types/HiddenAttribute.cs
@@ -1,8 +1,7 @@
namespace Genocs.Common.Types;
-
///
-/// It defines whether the attribute is hidden or not
+/// It defines whether the attribute is hidden or not.
///
[AttributeUsage(AttributeTargets.Property)]
public class HiddenAttribute : Attribute
diff --git a/src/Genocs.Common/Types/IIdentifiable.cs b/src/Genocs.Common/Types/IIdentifiable.cs
index 0da19004..e7ff2efb 100644
--- a/src/Genocs.Common/Types/IIdentifiable.cs
+++ b/src/Genocs.Common/Types/IIdentifiable.cs
@@ -1,19 +1,13 @@
namespace Genocs.Common.Types;
///
-/// Identifiable interface definition
+/// Identifiable interface definition.
///
-///
+/// The Identifiable type.
public interface IIdentifiable
{
///
- /// The Id getter
+ /// The Id getter.
///
T Id { get; }
-
- ///
- /// Checks if this entity is transient (not persisted to database and it has not an ).
- ///
- /// True, if this entity is transient
- bool IsTransient();
}
\ No newline at end of file
diff --git a/src/Genocs.Common/Types/IInitializer.cs b/src/Genocs.Common/Types/IInitializer.cs
index a0390f2b..6c9ff8f9 100644
--- a/src/Genocs.Common/Types/IInitializer.cs
+++ b/src/Genocs.Common/Types/IInitializer.cs
@@ -1,13 +1,13 @@
namespace Genocs.Common.Types;
///
-/// Initializer interface definition
+/// Initializer interface definition.
///
public interface IInitializer
{
///
- /// Standard initializer
+ /// Standard initializer.
///
- ///
+ /// The Task.
Task InitializeAsync();
}
\ No newline at end of file
diff --git a/src/Genocs.Common/Types/IStartupInitializer.cs b/src/Genocs.Common/Types/IStartupInitializer.cs
index b78123b4..c6061dcb 100644
--- a/src/Genocs.Common/Types/IStartupInitializer.cs
+++ b/src/Genocs.Common/Types/IStartupInitializer.cs
@@ -1,14 +1,13 @@
namespace Genocs.Common.Types;
-
///
-/// Startup initializer interface definition
+/// Startup initializer interface definition.
///
public interface IStartupInitializer : IInitializer
{
///
- /// It allows to add an initializer
+ /// It allows to add an initializer.
///
- ///
+ /// The initializer.
void AddInitializer(IInitializer initializer);
}
\ No newline at end of file
diff --git a/src/Genocs.Common/Types/MessageAttribute.cs b/src/Genocs.Common/Types/MessageAttribute.cs
index 5dbc8107..224aa048 100644
--- a/src/Genocs.Common/Types/MessageAttribute.cs
+++ b/src/Genocs.Common/Types/MessageAttribute.cs
@@ -1,43 +1,43 @@
namespace Genocs.Common.Types;
///
-/// MessageAttribute class
+/// MessageAttribute class.
///
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public class MessageAttribute : Attribute
{
///
- /// The Exchange used by the system
+ /// The Exchange used by the system.
///
public string Exchange { get; }
///
- /// The Topic used to send/receive message
+ /// The Topic used to send/receive message.
///
public string Topic { get; }
///
- /// The queue
+ /// The queue.
///
public string Queue { get; }
///
- /// The type of the queue
+ /// The type of the queue.
///
public string QueueType { get; }
///
- /// The error
+ /// The error.
///
public string ErrorQueue { get; }
///
- /// The subscriptionId
+ /// The subscriptionId.
///
public string SubscriptionId { get; }
///
- /// Standard constructor
+ /// Standard constructor.
///
///
///
@@ -45,8 +45,13 @@ public class MessageAttribute : Attribute
///
///
///
- public MessageAttribute(string? exchange = null, string? topic = null, string? queue = null,
- string? queueType = null, string? errorQueue = null, string? subscriptionId = null)
+ public MessageAttribute(
+ string? exchange = null,
+ string? topic = null,
+ string? queue = null,
+ string? queueType = null,
+ string? errorQueue = null,
+ string? subscriptionId = null)
{
Exchange = exchange ?? string.Empty;
Topic = topic ?? string.Empty;
diff --git a/src/Genocs.Common/Types/PublicContractAttribute.cs b/src/Genocs.Common/Types/PublicContractAttribute.cs
index 9f669695..e3ab8e01 100644
--- a/src/Genocs.Common/Types/PublicContractAttribute.cs
+++ b/src/Genocs.Common/Types/PublicContractAttribute.cs
@@ -1,7 +1,7 @@
namespace Genocs.Common.Types;
///
-/// PublicContractAttribute class
+/// PublicContractAttribute class.
///
[AttributeUsage(AttributeTargets.Class)]
public class PublicContractAttribute : Attribute
diff --git a/src/Genocs.Core.Demo.Contracts/Genocs.Core.Demo.Contracts.csproj b/src/Genocs.Core.Demo.Contracts/Genocs.Core.Demo.Contracts.csproj
index ab4014c3..69c454cc 100644
--- a/src/Genocs.Core.Demo.Contracts/Genocs.Core.Demo.Contracts.csproj
+++ b/src/Genocs.Core.Demo.Contracts/Genocs.Core.Demo.Contracts.csproj
@@ -1,21 +1,17 @@
-
- net7.0
- enable
- enable
- false
- false
-
+
+ net8.0
+ false
+ false
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
diff --git a/src/Genocs.Core.Demo.Contracts/OrderRequestEvent.cs b/src/Genocs.Core.Demo.Contracts/OrderRequestEvent.cs
index fe8bbb30..76c37cf5 100644
--- a/src/Genocs.Core.Demo.Contracts/OrderRequestEvent.cs
+++ b/src/Genocs.Core.Demo.Contracts/OrderRequestEvent.cs
@@ -7,7 +7,6 @@ public class OrderRequest : IEvent
public string OrderId { get; set; } = Guid.NewGuid().ToString();
public string UserId { get; set; } = default!;
public DateTime TimeStamp { get; set; } = DateTime.UtcNow;
- public string CardToken { get; set; } = default!;
public decimal Amount { get; set; }
public string Currency { get; set; } = default!;
diff --git a/src/Genocs.Core.Demo.Domain/Aggregates/BaseAggregate.cs b/src/Genocs.Core.Demo.Domain/Aggregates/BaseAggregate.cs
new file mode 100644
index 00000000..f0eede68
--- /dev/null
+++ b/src/Genocs.Core.Demo.Domain/Aggregates/BaseAggregate.cs
@@ -0,0 +1,24 @@
+using Genocs.Core.Domain.Entities;
+using Genocs.Core.Domain.Entities.Auditing;
+using Genocs.Persistence.MongoDb.Domain.Entities;
+using MongoDB.Bson;
+
+namespace Genocs.Core.Demo.Domain.Aggregates;
+
+///
+/// Base aggregate class used for all entities.
+/// This class is used to define some common properties for all entities.
+///
+public class BaseAggregate : AggregateRoot, IMongoDbEntity, IHasCreationTime
+{
+ public BaseAggregate()
+ {
+ // Set the unique identifier for the entity generates a new ObjectId.
+ Id = ObjectId.GenerateNewId();
+ }
+
+ ///
+ /// Creation time of this entity.
+ ///
+ public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
+}
\ No newline at end of file
diff --git a/src/Genocs.Core.Demo.Domain/Aggregates/Order.cs b/src/Genocs.Core.Demo.Domain/Aggregates/Order.cs
index c7b7d5f6..0a8c3080 100644
--- a/src/Genocs.Core.Demo.Domain/Aggregates/Order.cs
+++ b/src/Genocs.Core.Demo.Domain/Aggregates/Order.cs
@@ -1,26 +1,21 @@
-using Genocs.Core.Domain.Entities;
-using Genocs.Core.Domain.Entities.Auditing;
-using Genocs.Core.Domain.Repositories;
-using Genocs.Persistence.MongoDb.Repositories;
+using Genocs.Core.Domain.Repositories;
+using MongoDB.Bson;
namespace Genocs.Core.Demo.Domain.Aggregates;
[TableMapping("Orders")]
-public class Order : AggregateRoot, IMongoDbEntity, IHasCreationTime
+public class Order : BaseAggregate
{
- public Order(string orderId, string userId, string cardToken, decimal amount, string currency)
+ public Order(string orderId, string userId, decimal amount, string currency)
{
OrderId = orderId;
UserId = userId;
- CardToken = cardToken;
Amount = amount;
Currency = currency;
}
- public string OrderId { get; set; } = Guid.NewGuid().ToString();
+ public string OrderId { get; set; } = ObjectId.GenerateNewId().ToString();
public string UserId { get; set; } = default!;
- public DateTime CreationTime { get; set; } = DateTime.UtcNow;
- public string CardToken { get; set; } = default!;
public decimal Amount { get; set; }
public string Currency { get; set; } = default!;
}
diff --git a/src/Genocs.Core.Demo.Domain/Aggregates/User.cs b/src/Genocs.Core.Demo.Domain/Aggregates/User.cs
index 2b241a42..94f13764 100644
--- a/src/Genocs.Core.Demo.Domain/Aggregates/User.cs
+++ b/src/Genocs.Core.Demo.Domain/Aggregates/User.cs
@@ -1,31 +1,20 @@
-using Genocs.Common.Types;
-using Genocs.Core.Domain.Entities.Auditing;
-using Genocs.Core.Domain.Repositories;
+using Genocs.Core.Domain.Repositories;
namespace Genocs.Core.Demo.Domain.Aggregates;
[TableMapping("Users")]
-public class User : IIdentifiable, IHasCreationTime
+public class User : BaseAggregate
{
-
- public Guid Id { get; set; }
public string UserId { get; set; } = default!;
- public DateTime CreationTime { get; set; } = DateTime.UtcNow;
public string Username { get; set; } = default!;
public decimal Age { get; set; }
public string Country { get; set; } = default!;
public User(string userId, string username, decimal age, string country)
{
- Id = Guid.NewGuid();
UserId = userId;
Username = username;
Age = age;
Country = country;
}
-
- public bool IsTransient()
- {
- return true;
- }
}
diff --git a/src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj b/src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj
index ae4a0a79..39f3fc59 100644
--- a/src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj
+++ b/src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj
@@ -1,21 +1,19 @@
-
- net7.0
- enable
- enable
- false
- false
-
+
+ net8.0
+ false
+ false
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/src/Genocs.Core.Demo.Infrastructure/Genocs.Core.Demo.Infrastructure.csproj b/src/Genocs.Core.Demo.Infrastructure/Genocs.Core.Demo.Infrastructure.csproj
index d32391db..dc1d6876 100644
--- a/src/Genocs.Core.Demo.Infrastructure/Genocs.Core.Demo.Infrastructure.csproj
+++ b/src/Genocs.Core.Demo.Infrastructure/Genocs.Core.Demo.Infrastructure.csproj
@@ -1,11 +1,9 @@
-
- net7.0
- enable
- enable
- false
- false
-
+
+ net8.0
+ false
+ false
+
diff --git a/src/Genocs.Core.Demo.WebApi/Configurations/ExternalServiceOptions.cs b/src/Genocs.Core.Demo.WebApi/Configurations/ExternalServiceOptions.cs
new file mode 100644
index 00000000..ef8b1db6
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Configurations/ExternalServiceOptions.cs
@@ -0,0 +1,41 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Genocs.Core.Demo.WebApi.Configurations;
+
+///
+/// This class implements Options pattern with Validation.
+///
+public class ExternalServiceOptions : IValidatableObject
+{
+ ///
+ /// Default section name.
+ ///
+ public const string Position = "externalService";
+
+ ///
+ /// It defines whether the section is enabled or not.
+ ///
+ public bool Enabled { get; set; }
+
+ public string Caller { get; set; } = default!;
+ public string Private { get; set; } = default!;
+ public string Public { get; set; } = default!;
+
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ if (string.IsNullOrWhiteSpace(Caller))
+ {
+ yield return new ValidationResult("No Caller defined in ExternalService config", new[] { nameof(Caller) });
+ }
+
+ if (string.IsNullOrWhiteSpace(Private))
+ {
+ yield return new ValidationResult("No Private defined in ExternalService config", new[] { nameof(Private) });
+ }
+
+ if (string.IsNullOrWhiteSpace(Public))
+ {
+ yield return new ValidationResult("No Public defined in ExternalService config", new[] { nameof(Public) });
+ }
+ }
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Configurations/RabbitMQOptions.cs b/src/Genocs.Core.Demo.WebApi/Configurations/RabbitMQOptions.cs
new file mode 100644
index 00000000..029daa12
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Configurations/RabbitMQOptions.cs
@@ -0,0 +1,22 @@
+namespace Genocs.Core.Demo.WebApi.Configurations;
+
+public class RabbitMQOptions
+{
+ ///
+ /// Default section name.
+ ///
+ public const string Position = "rabbitMQ";
+
+ ///
+ /// It defines whether the section is enabled or not.
+ ///
+ public bool Enabled { get; set; }
+
+ public string HostName { get; set; } = default!;
+ public string VirtualHost { get; set; } = default!;
+ public string UserName { get; set; } = default!;
+ public string Password { get; set; } = default!;
+ public int Port { get; set; } = default!;
+ public bool UseSSL { get; set; }
+
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Configurations/SecretOptions.cs b/src/Genocs.Core.Demo.WebApi/Configurations/SecretOptions.cs
new file mode 100644
index 00000000..367033fc
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Configurations/SecretOptions.cs
@@ -0,0 +1,20 @@
+namespace Genocs.Core.Demo.WebApi.Configurations;
+
+public class SecretOptions
+{
+ ///
+ /// Default section name.
+ ///
+ public const string Position = "secrets";
+
+ ///
+ /// It defines whether the section is enabled or not.
+ ///
+ public bool Enabled { get; set; }
+
+ ///
+ /// This is an example of a secret. That should be stored in a secure way.
+ ///
+ public string? Secret { get; set; }
+
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Configurations/VerificationServiceOptions.cs b/src/Genocs.Core.Demo.WebApi/Configurations/VerificationServiceOptions.cs
new file mode 100644
index 00000000..d33ab6a4
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Configurations/VerificationServiceOptions.cs
@@ -0,0 +1,16 @@
+namespace Genocs.Core.Demo.WebApi.Configurations;
+
+public class VerificationServiceOptions
+{
+ ///
+ /// Default section name.
+ ///
+ public const string Position = "verificationService";
+
+ ///
+ /// It defines whether the section is enabled or not.
+ ///
+ public bool Enabled { get; set; }
+
+ public string ApiKey { get; set; } = default!;
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Controllers/AuthorizedController.cs b/src/Genocs.Core.Demo.WebApi/Controllers/AuthorizedController.cs
new file mode 100644
index 00000000..8d496c13
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Controllers/AuthorizedController.cs
@@ -0,0 +1,26 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System.Net.Mime;
+
+namespace Genocs.Core.Demo.WebApi.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+[Authorize]
+public class AuthorizedController : ControllerBase
+{
+ private readonly ILogger _logger;
+
+ public AuthorizedController(ILogger logger)
+ {
+ _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ }
+
+ [HttpGet("GetAuthorized")]
+ [Consumes(MediaTypeNames.Application.Json)]
+ [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
+ public async Task PostSubmitDemoCommand()
+ {
+ return await Task.Run(() => Ok($"Done! Authorization is: {HttpContext.Request.Headers["Authorization"]}"));
+ }
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Controllers/ExternalApiController.cs b/src/Genocs.Core.Demo.WebApi/Controllers/ExternalApiController.cs
new file mode 100644
index 00000000..6d6b975a
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Controllers/ExternalApiController.cs
@@ -0,0 +1,34 @@
+using Genocs.Core.Demo.WebApi.Infrastructure.Services;
+using Microsoft.AspNetCore.Mvc;
+using System.Net.Mime;
+
+namespace Genocs.Core.Demo.WebApi.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class ExternalApiController : ControllerBase
+{
+ private readonly ILogger _logger;
+ private readonly IExternalServiceClient _externalServiceClient;
+
+ public ExternalApiController(
+ ILogger logger,
+ IExternalServiceClient externalServiceClient)
+ {
+ _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ _externalServiceClient = externalServiceClient ?? throw new ArgumentNullException(nameof(externalServiceClient));
+ }
+
+ [HttpGet("")]
+ [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
+ [Consumes(MediaTypeNames.Application.Json)]
+ public async Task HomeAsync()
+ => await Task.Run(() => Ok("done"));
+
+ [HttpPost("")]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IssuingResponse), StatusCodes.Status200OK)]
+ [Consumes(MediaTypeNames.Application.Json)]
+ public async Task PostIssueAsync(IssuingRequest request)
+ => Ok(await _externalServiceClient.IssueAsync(request));
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Controllers/HomeController.cs b/src/Genocs.Core.Demo.WebApi/Controllers/HomeController.cs
index 823bf70f..d9a29280 100644
--- a/src/Genocs.Core.Demo.WebApi/Controllers/HomeController.cs
+++ b/src/Genocs.Core.Demo.WebApi/Controllers/HomeController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Mvc;
+using Genocs.Core.Demo.WebApi.Configurations;
+using Microsoft.AspNetCore.Mvc;
namespace Genocs.Core.Demo.WebApi.Controllers;
@@ -6,6 +7,13 @@ namespace Genocs.Core.Demo.WebApi.Controllers;
[Route("")]
public class HomeController : ControllerBase
{
+ public readonly SecretOptions _secretSettings;
+
+ public HomeController(SecretOptions secretSettings)
+ {
+ _secretSettings = secretSettings ?? throw new ArgumentNullException(nameof(secretSettings));
+ }
+
[HttpGet]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
public IActionResult Get()
@@ -15,4 +23,9 @@ public IActionResult Get()
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
public IActionResult Ping()
=> Ok("pong");
+
+ [HttpGet("secret")]
+ [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
+ public IActionResult GetSecret()
+ => Ok($"Read: {_secretSettings.Secret}");
}
diff --git a/src/Genocs.Core.Demo.WebApi/Controllers/MongoDbController.cs b/src/Genocs.Core.Demo.WebApi/Controllers/MongoDbController.cs
index 69e79b7b..5fbd6f2d 100644
--- a/src/Genocs.Core.Demo.WebApi/Controllers/MongoDbController.cs
+++ b/src/Genocs.Core.Demo.WebApi/Controllers/MongoDbController.cs
@@ -1,8 +1,6 @@
using Genocs.Core.Demo.Domain.Aggregates;
-using Genocs.Core.Domain.Repositories;
-using Genocs.Persistence.MongoDb.Repositories;
+using Genocs.Persistence.MongoDb.Domain.Repositories;
using Microsoft.AspNetCore.Mvc;
-using MongoDB.Bson;
namespace Genocs.Core.Demo.WebApi.Controllers;
diff --git a/src/Genocs.Core.Demo.WebApi/Controllers/ServiceBusController.cs b/src/Genocs.Core.Demo.WebApi/Controllers/ServiceBusController.cs
index 2b4d2d63..f8f874a6 100644
--- a/src/Genocs.Core.Demo.WebApi/Controllers/ServiceBusController.cs
+++ b/src/Genocs.Core.Demo.WebApi/Controllers/ServiceBusController.cs
@@ -22,7 +22,6 @@ public ServiceBusController(ILogger logger, IAzureServiceB
_azureServiceBusTopic = azureServiceBusTopic;
}
-
[HttpPost("SendToQueueAzureServiceBusQueue")]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
@@ -61,7 +60,6 @@ public async Task PostSubmitOrder()
{
OrderId = Guid.NewGuid().ToString(),
UserId = Guid.NewGuid().ToString(),
- CardToken = "6500-1254-2548",
Amount = 10.0M,
Currency = "EUR",
Basket = new List()
diff --git a/src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj b/src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj
index 41790cf1..8b857be6 100644
--- a/src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj
+++ b/src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj
@@ -1,29 +1,46 @@
-
- net7.0
- enable
- enable
- false
- false
- __genocs
- Linux
- ..\..
-
+
+ net8.0
+ false
+ false
+ genocs
+ Linux
+ ..\..
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/BuilderExtensions.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/BuilderExtensions.cs
new file mode 100644
index 00000000..3d955bc0
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/BuilderExtensions.cs
@@ -0,0 +1,51 @@
+using Genocs.Core.Builders;
+using Genocs.Core.Demo.WebApi.Configurations;
+using Genocs.Core.Demo.WebApi.Infrastructure.Services;
+using Genocs.HTTP;
+using Genocs.Security;
+using Genocs.WebApi.Security;
+
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Extensions;
+
+public static class BuilderExtensions
+{
+ ///
+ /// Extension method to add application services to the DI container.
+ ///
+ /// The Genocs builder.
+ /// The Genocs builder to be used for chain.
+ public static IGenocsBuilder AddApplicationServices(this IGenocsBuilder builder)
+ {
+ // Add the Security services
+ builder.AddSecurity();
+
+ // Add the Certification Authentication
+ builder.AddCertificateAuthentication();
+
+ // Add the Genocs Http client
+ builder.AddHttpClient();
+
+ // Add the External Service settings
+ // Option 1: In this way ExternalServiceSettings is available for dependency injection.
+ // var settings = new ExternalServiceSettings();
+ // builder.Configuration.GetSection(ExternalServiceSettings.Position).Bind(settings);
+ // builder.Services.AddSingleton(settings);
+
+ // Option 2: In this way ExternalServiceSettings is available for dependency injection. By using IOptions you can access the settings.
+ builder.Services.AddOptions()
+ .BindConfiguration(ExternalServiceOptions.Position)
+ .ValidateDataAnnotations()
+ .ValidateOnStart();
+
+ // builder.Services.AddSingleton, ConfigureWebApiSettings>();
+ ExternalServiceOptions settings = builder.Configuration.GetOptions(ExternalServiceOptions.Position);
+ builder.Services.AddSingleton(settings);
+
+ // Add the External Service http Client
+ builder.Services.AddTransient();
+
+ // builder.Services.Configure(builder.Configuration.GetSection(ExternalServiceSettings.Position));
+
+ return builder;
+ }
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/ServiceCollectionExtensions.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/ServiceCollectionExtensions.cs
index ef682b8b..de255e2f 100644
--- a/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/ServiceCollectionExtensions.cs
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Extensions/ServiceCollectionExtensions.cs
@@ -1,5 +1,5 @@
-using Genocs.Core.Demo.WebApi.Options;
-using Genocs.ServiceBusAzure.Options;
+using Genocs.Core.Demo.WebApi.Configurations;
+using Genocs.ServiceBusAzure.Configurations;
using Genocs.ServiceBusAzure.Queues;
using Genocs.ServiceBusAzure.Queues.Interfaces;
using Genocs.ServiceBusAzure.Topics;
@@ -21,7 +21,7 @@ public static IServiceCollection AddAzureServiceBus(this IServiceCollection serv
public static IServiceCollection AddAzureServiceBusTopic(this IServiceCollection services, IConfiguration configuration)
{
// Register IOptions
- services.Configure(configuration.GetSection(AzureServiceBusTopicSettings.Position));
+ services.Configure(configuration.GetSection(AzureServiceBusTopicOptions.Position));
// HOW to Register TopicSettings instead of IOptions
////var topicSetting = new TopicOptions();
@@ -36,7 +36,7 @@ public static IServiceCollection AddAzureServiceBusTopic(this IServiceCollection
public static IServiceCollection AddAzureServiceBusQueue(this IServiceCollection services, IConfiguration configuration)
{
// Register IOptions
- services.Configure(configuration.GetSection(AzureServiceBusQueueSettings.Position));
+ services.Configure(configuration.GetSection(AzureServiceBusQueueOptions.Position));
// HOW to Register QueueSettings instead of IOptions
////var queueSetting = new QueueSettings();
@@ -50,8 +50,11 @@ public static IServiceCollection AddAzureServiceBusQueue(this IServiceCollection
public static IServiceCollection AddCustomMassTransit(this IServiceCollection services, IConfiguration configuration)
{
- var rabbitMQSettings = new RabbitMQSettings();
- configuration.GetSection(RabbitMQSettings.Position).Bind(rabbitMQSettings);
+ RabbitMQOptions rabbitMQSettings = new RabbitMQOptions();
+ configuration.GetSection(RabbitMQOptions.Position).Bind(rabbitMQSettings);
+
+ // This is another way to get the RabbitMQOptions
+ // RabbitMQOptions? rabbitMQSettingsV2 = configuration.GetSection(RabbitMQOptions.Position).Get();
services.AddSingleton(rabbitMQSettings);
@@ -62,17 +65,24 @@ public static IServiceCollection AddCustomMassTransit(this IServiceCollection se
x.UsingRabbitMq((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
- //cfg.UseHealthCheck(context);
- cfg.Host(rabbitMQSettings.HostName, rabbitMQSettings.VirtualHost,
- h =>
- {
- h.Username(rabbitMQSettings.UserName);
- h.Password(rabbitMQSettings.Password);
- }
- );
+
+ // cfg.UseHealthCheck(context);
+ cfg.Host(
+ rabbitMQSettings.HostName,
+ rabbitMQSettings.VirtualHost,
+ h =>
+ {
+ h.Username(rabbitMQSettings.UserName);
+ h.Password(rabbitMQSettings.Password);
+ });
});
});
return services;
}
+
+ public static IApplicationBuilder UseFirebaseAuthentication(this IApplicationBuilder builder)
+ {
+ return builder.UseMiddleware();
+ }
}
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/FirebaseAuthenticationMiddleware.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/FirebaseAuthenticationMiddleware.cs
new file mode 100644
index 00000000..5d0e953a
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/FirebaseAuthenticationMiddleware.cs
@@ -0,0 +1,55 @@
+using System.IdentityModel.Tokens.Jwt;
+using System.Security.Claims;
+
+namespace Genocs.Core.Demo.WebApi.Infrastructure;
+
+///
+/// Middleware authentication. Used to implement OpenId JWT implementation.
+///
+public class FirebaseAuthenticationMiddleware
+{
+ private readonly RequestDelegate _next;
+
+ public FirebaseAuthenticationMiddleware(RequestDelegate next)
+ {
+ _next = next;
+ }
+
+ public async Task Invoke(HttpContext context)
+ {
+ string authHeader = context.Request.Headers["Authorization"].ToString();
+
+ if (authHeader != null && authHeader.StartsWith("Bearer "))
+ {
+ string token = authHeader.Substring("Bearer ".Length).Trim();
+
+ try
+ {
+ var handler = new JwtSecurityTokenHandler();
+ var jsonToken = handler.ReadToken(token) as JwtSecurityToken;
+
+ var jwtToken = new JwtSecurityToken(token);
+ var payload = jwtToken.Payload;
+ var claims = new[]
+ {
+ new Claim(ClaimTypes.NameIdentifier, payload["user_id"].ToString()),
+ new Claim(ClaimTypes.Name, payload["name"].ToString()),
+
+ // Add more claims as needed
+ };
+
+ var identity = new ClaimsIdentity(claims, "Firebase");
+ context.User = new ClaimsPrincipal(identity);
+ }
+ catch (Exception ex)
+ {
+ // Token validation failed
+ context.Response.StatusCode = 401;
+ await context.Response.WriteAsync("Unauthorized");
+ return;
+ }
+ }
+
+ await _next(context);
+ }
+}
\ No newline at end of file
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/ExternalServiceClient.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/ExternalServiceClient.cs
new file mode 100644
index 00000000..6ca25116
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/ExternalServiceClient.cs
@@ -0,0 +1,84 @@
+using Genocs.Core.Demo.WebApi.Configurations;
+using Genocs.HTTP;
+using Genocs.HTTP.Configurations;
+using Genocs.Security;
+using Microsoft.Extensions.Options;
+using Newtonsoft.Json;
+
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Services;
+
+///
+/// The External WebApi client implementation.
+///
+public class ExternalServiceClient : IExternalServiceClient
+{
+ private readonly IHttpClient _client;
+ private readonly string _url;
+ private readonly IHasher _hasher;
+ private readonly ExternalServiceOptions _externalServiceOptions;
+
+ ///
+ /// The standard constructor.
+ ///
+ /// The http client.
+ /// The Hash service.
+ /// The http client settings.
+ /// The security settings.
+ public ExternalServiceClient(
+ IHttpClient client,
+ IHasher hasher,
+ HttpClientOptions httpClientSettings,
+ IOptions options)
+ {
+ _client = client ?? throw new ArgumentNullException(nameof(client));
+ _hasher = hasher ?? throw new ArgumentNullException(nameof(hasher));
+ _externalServiceOptions = options.Value ?? throw new ArgumentNullException(nameof(options));
+
+ if (httpClientSettings is null)
+ {
+ throw new ArgumentNullException(nameof(httpClientSettings));
+ }
+
+ string? url = httpClientSettings?.Services?["ca_issuer"];
+
+ if (string.IsNullOrWhiteSpace(url))
+ {
+ throw new Exception("products http client settings cannot be null");
+ }
+
+ _url = url;
+ }
+
+ private void SetHeaders(string request)
+ {
+ string hash = _hasher.Hash(request, _externalServiceOptions.Private);
+ string headerData = $"Credential={_externalServiceOptions.Public}, Signature={hash}";
+ _client.SetHeaders(h => h.TryAddWithoutValidation("Authorization", headerData));
+ }
+
+ ///
+ /// Send a request for gift card issuing.
+ ///
+ /// The issuing Request.
+ /// The issuing Response containing the gift card details.
+ public async Task IssueAsync(IssuingRequest request)
+ {
+ string serializedRequest = JsonConvert.SerializeObject(request);
+ SetHeaders(serializedRequest);
+ using (var content = new StringContent(serializedRequest, System.Text.Encoding.UTF8, "application/json"))
+ {
+ return await _client.PostAsync($"{_url}/redemptions/gift-cards/{_externalServiceOptions.Caller}/direct-issue", content);
+ }
+ }
+
+ ///
+ /// Get the product based on the productId.
+ ///
+ /// The redemption request.
+ /// The redemption Response.
+ public async Task RedeemAsync(RedemptionRequest request)
+ {
+ // SetHeaders(callerId);
+ return await _client.PostAsync($"{_url}/redemptions/gift-cards/custom/redeem", request);
+ }
+}
\ No newline at end of file
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IExternalServiceClient.Models.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IExternalServiceClient.Models.cs
new file mode 100644
index 00000000..aeb41244
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IExternalServiceClient.Models.cs
@@ -0,0 +1,151 @@
+using Newtonsoft.Json;
+
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Services;
+
+///
+/// The request object for the issuing endpoint.
+///
+public class IssuingRequest
+{
+ [JsonProperty("external_reference")]
+ public string? ExternalReference;
+
+ [JsonProperty("loyalty_currency")]
+ public string? Currency;
+
+ [JsonProperty("fiat_amount")]
+ public decimal Amount;
+
+ [JsonProperty("partner_code")]
+ public string? PartnerCode;
+}
+
+///
+/// The request object for the redemption endpoint.
+///
+public class RedemptionRequest
+{
+
+}
+
+public class Metadata
+{
+ [JsonProperty("memberId")]
+ public string? MemberId { get; set; }
+
+ [JsonProperty("requestId")]
+ public string? RequestId { get; set; }
+
+ [JsonProperty("email")]
+ public string? Email { get; set; }
+}
+
+///
+/// The response object for the issuing endpoint.
+///
+public class IssuingResponse
+{
+ [JsonProperty("code")]
+ public CodeResponse? Code { get; set; }
+
+ [JsonProperty("gift_card")]
+ public GiftCard? GiftCard { get; set; }
+}
+
+///
+/// The Code data available in the response object.
+///
+public class CodeResponse
+{
+ [JsonProperty("id")]
+ public string? Id { get; set; }
+
+ [JsonProperty("code")]
+ public string? Code { get; set; }
+
+ [JsonProperty("barcode_string")]
+ public string? Barcode { get; set; }
+
+ [JsonProperty("barcode_format")]
+ public string? BarcodeFormat { get; set; }
+
+ [JsonProperty("discount_amount")]
+ public int DiscountAmount { get; set; }
+
+ [JsonProperty("delivery_url")]
+ public object? DeliveryUrl { get; set; }
+
+ [JsonProperty("expiration_date")]
+ public string? ExpirationDate { get; set; }
+
+ [JsonProperty("fiat_amount")]
+ public string? FiatAmount { get; set; }
+
+ [JsonProperty("fiat_balance")]
+ public string? FiatBalance { get; set; }
+
+ [JsonProperty("fiat_currency")]
+ public string? FiatCurrency { get; set; }
+
+ [JsonProperty("issuance_details")]
+ public IssuanceDetails? IssuanceDetails { get; set; }
+
+ [JsonProperty("pin")]
+ public string? Pin { get; set; }
+
+ [JsonProperty("redemption_details")]
+ public object? RedemptionDetails { get; set; }
+
+ [JsonProperty("redemption_status")]
+ public string? RedemptionStatus { get; set; }
+}
+
+public class CustomSettingsData
+{
+}
+
+public class GiftCard
+{
+ [JsonProperty("barcode_format")]
+ public string? BarcodeFormat { get; set; }
+
+ public List countries { get; set; }
+ public string currency { get; set; }
+ public CustomSettingsData custom_settings_data { get; set; }
+ public string denomination_type { get; set; }
+ public List denominations { get; set; }
+ public string description { get; set; }
+
+ // public int discount_value { get; set; }
+ public string expiration_policy { get; set; }
+ public string id { get; set; }
+ public object image { get; set; }
+ public string maximum_value { get; set; }
+ public string minimum_value { get; set; }
+ public string name { get; set; }
+ public string provider { get; set; }
+ public string redeem_instructions_html { get; set; }
+ public string terms_and_conditions_html { get; set; }
+ public string terms_and_conditions_url { get; set; }
+ public string type { get; set; }
+}
+
+public class IssuanceDetails
+{
+ public CustomSettingsData custom_settings_data { get; set; }
+ public string external_reference { get; set; }
+ public LoyaltyInformation loyalty_information { get; set; }
+
+ // public Metadata metadata { get; set; }
+ public string original_external_reference { get; set; }
+ public string original_code { get; set; }
+ public string partner_code { get; set; }
+}
+
+public class LoyaltyInformation
+{
+ // public int? loyalty_amount { get; set; }
+ public string loyalty_currency { get; set; }
+ public string member_id { get; set; }
+ public string partner_name { get; set; }
+}
\ No newline at end of file
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IExternalServiceClient.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IExternalServiceClient.cs
new file mode 100644
index 00000000..443112b0
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IExternalServiceClient.cs
@@ -0,0 +1,21 @@
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Services;
+
+///
+/// The External WebApi client definition.
+///
+public interface IExternalServiceClient
+{
+ ///
+ /// Send a request for gift card issuing.
+ ///
+ /// The issuing Request.
+ /// The issuing Response containing the gift card details.
+ Task IssueAsync(IssuingRequest request);
+
+ ///
+ /// Get the product based on the productId.
+ ///
+ /// The redemption request.
+ /// The redemption Response.
+ Task RedeemAsync(RedemptionRequest request);
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IVerificationServiceClient.Models.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IVerificationServiceClient.Models.cs
new file mode 100644
index 00000000..221a71f2
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IVerificationServiceClient.Models.cs
@@ -0,0 +1,66 @@
+using Newtonsoft.Json;
+
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Services;
+
+///
+/// The Internal User verification request.
+///
+public class VerificationApiRequest
+{
+ [JsonProperty("type")]
+ public string? Type { get; set; }
+
+ [JsonProperty("joinedDate")]
+ public string? JoinedDate { get; set; }
+
+ [JsonProperty("email")]
+ public string? Email { get; set; }
+
+ [JsonProperty("personDetails")]
+ public PersonDetailsRequest? Details { get; set; }
+}
+
+public class PersonDetailsRequest
+{
+ [JsonProperty("firstName")]
+ public string? FirstName { get; set; }
+
+ [JsonProperty("lastName")]
+ public string? LastName { get; set; }
+
+ [JsonProperty("dob")]
+ public string? DateOfBirth { get; set; }
+
+ [JsonProperty("gender")]
+ public string? Gender { get; set; }
+
+ [JsonProperty("nationality")]
+ public string? Nationality { get; set; }
+}
+
+///
+/// The internal User verification response.
+///
+public class VerificationApiResponse
+{
+ [JsonProperty("id")]
+ public string? Id { get; set; }
+
+ [JsonProperty("createdAt")]
+ public string? CreatedAt { get; set; }
+
+ [JsonProperty("updatedAt")]
+ public string? UpdatedAt { get; set; }
+
+ [JsonProperty("type")]
+ public string? Type { get; set; }
+
+ [JsonProperty("joinedDate")]
+ public string? JoinedDate { get; set; }
+
+ [JsonProperty("email")]
+ public string? Email { get; set; }
+
+ [JsonProperty("personDetails")]
+ public PersonDetailsRequest? Details { get; set; }
+}
\ No newline at end of file
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IVerificationServiceClient.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IVerificationServiceClient.cs
new file mode 100644
index 00000000..7129c59f
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/IVerificationServiceClient.cs
@@ -0,0 +1,15 @@
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Services;
+
+///
+/// The External WebApi client definition.
+/// This API client is used to verify the user.
+///
+public interface IVerificationServiceClient
+{
+ ///
+ /// Send a request To verify the user.
+ ///
+ /// The request with the user data.
+ /// The user verification response.
+ Task VerifyAsync(VerificationApiRequest request);
+}
diff --git a/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/VerificationServiceClient.cs b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/VerificationServiceClient.cs
new file mode 100644
index 00000000..4820e3ae
--- /dev/null
+++ b/src/Genocs.Core.Demo.WebApi/Infrastructure/Services/VerificationServiceClient.cs
@@ -0,0 +1,65 @@
+using Genocs.Core.Demo.WebApi.Configurations;
+using Genocs.HTTP;
+using Genocs.HTTP.Configurations;
+using Newtonsoft.Json;
+
+namespace Genocs.Core.Demo.WebApi.Infrastructure.Services;
+
+///
+/// The Verification WebApi client implementation.
+///
+public class VerificationServiceClient : IVerificationServiceClient
+{
+ private readonly IHttpClient _client;
+ private readonly string _url;
+ private readonly VerificationServiceOptions _externalServiceSettings;
+
+ ///
+ /// The standard constructor.
+ ///
+ /// The http client.
+ /// The http client settings.
+ /// The security settings.
+ public VerificationServiceClient(
+ IHttpClient client,
+ HttpClientOptions httpClientSettings,
+ VerificationServiceOptions externalServiceSettings)
+ {
+ _client = client ?? throw new ArgumentNullException(nameof(client));
+ _externalServiceSettings = externalServiceSettings ?? throw new ArgumentNullException(nameof(externalServiceSettings));
+
+ if (httpClientSettings is null)
+ {
+ throw new ArgumentNullException(nameof(httpClientSettings));
+ }
+
+ string? url = httpClientSettings?.Services?["user_verifier"];
+
+ if (string.IsNullOrWhiteSpace(url))
+ {
+ throw new Exception("user_verifier http client settings cannot be null");
+ }
+
+ _url = url;
+ }
+
+ private void SetHeaders()
+ {
+ _client.SetHeaders(h => h.TryAddWithoutValidation("Authorization", _externalServiceSettings.ApiKey));
+ }
+
+ ///
+ /// The method to verify the user.
+ ///
+ /// The verification api request.
+ /// The response.
+ public async Task VerifyAsync(VerificationApiRequest request)
+ {
+ SetHeaders();
+ string serializedRequest = JsonConvert.SerializeObject(request);
+ using (var content = new StringContent(serializedRequest, System.Text.Encoding.UTF8, "application/json"))
+ {
+ return await _client.PostAsync($"{_url}/clients", request);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Genocs.Core.Demo.WebApi/Options/RabbitMQSettings.cs b/src/Genocs.Core.Demo.WebApi/Options/RabbitMQSettings.cs
deleted file mode 100644
index 0afe6136..00000000
--- a/src/Genocs.Core.Demo.WebApi/Options/RabbitMQSettings.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Genocs.Core.Demo.WebApi.Options;
-
-public class RabbitMQSettings
-{
- public const string Position = "RabbitMQ";
-
- public string HostName { get; set; } = default!;
- public string VirtualHost { get; set; } = default!;
- public string UserName { get; set; } = default!;
- public string Password { get; set; } = default!;
- public int Port { get; set; } = default!;
- public bool UseSSL { get; set; }
-
-}
diff --git a/src/Genocs.Core.Demo.WebApi/Program.cs b/src/Genocs.Core.Demo.WebApi/Program.cs
index f5ea325f..e0b37556 100644
--- a/src/Genocs.Core.Demo.WebApi/Program.cs
+++ b/src/Genocs.Core.Demo.WebApi/Program.cs
@@ -1,38 +1,36 @@
+// using Genocs.Auth;
using Genocs.Core.Builders;
+using Genocs.Core.Demo.WebApi.Configurations;
using Genocs.Core.Demo.WebApi.Infrastructure.Extensions;
using Genocs.Logging;
-using Genocs.Monitoring;
using Genocs.Persistence.MongoDb.Extensions;
+using Genocs.Secrets.AzureKeyVault;
+using Genocs.Tracing;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Serilog;
-using Serilog.Events;
+using Genocs.Auth;
using System.Reflection;
using System.Text.Json.Serialization;
-Log.Logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
- .MinimumLevel.Override("MassTransit", LogEventLevel.Information)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .CreateLogger();
-
+StaticLogger.EnsureInitialized();
var builder = WebApplication.CreateBuilder(args);
builder.Host
+ .UseAzureKeyVault()
.UseLogging();
-// .UseVault();
-
-// add services to DI container
var services = builder.Services;
services
.AddGenocs(builder.Configuration)
+ .AddJwt()
+// .AddOpenIdJwt()
+ .AddOpenTelemetry()
.AddMongoFast()
- .RegisterMongoRepositories(Assembly.GetExecutingAssembly());
-
+ .RegisterMongoRepositories(Assembly.GetExecutingAssembly())
+ .AddApplicationServices()
+ .Build();
services.AddCors();
services.AddControllers().AddJsonOptions(x =>
@@ -43,6 +41,11 @@
services.AddHealthChecks();
+services.Configure(builder.Configuration.GetSection(SecretOptions.Position));
+
+SecretOptions settings = builder.Configuration.GetOptions(SecretOptions.Position);
+services.AddSingleton(settings);
+
services.Configure(options =>
{
options.Delay = TimeSpan.FromSeconds(2);
@@ -56,15 +59,10 @@
// Add Masstransit bus configuration
services.AddCustomMassTransit(builder.Configuration);
-
services.AddOptions();
-// Set Custom Open telemetry
-services.AddCustomOpenTelemetry(builder.Configuration);
-
var app = builder.Build();
-
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
@@ -72,7 +70,6 @@
app.UseSwaggerUI();
}
-
// global cors policy
app.UseCors(x => x
.SetIsOriginAllowed(origin => true)
@@ -80,16 +77,18 @@
.AllowAnyHeader()
.AllowCredentials());
-
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
+// Use it only if you need to authenticate with Firebase
+// app.UseFirebaseAuthentication();
+
app.MapControllers();
-app.MapHealthChecks("/healthz");
+app.MapHealthChecks("/hc");
app.Run();
diff --git a/src/Genocs.Core.Demo.WebApi/appsettings.Development.json b/src/Genocs.Core.Demo.WebApi/appsettings.Development.json
deleted file mode 100644
index 12fcb59b..00000000
--- a/src/Genocs.Core.Demo.WebApi/appsettings.Development.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Information",
- "Microsoft": "Information",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- }
-}
diff --git a/src/Genocs.Core.Demo.WebApi/appsettings.json b/src/Genocs.Core.Demo.WebApi/appsettings.json
index 8bb32dc4..34a70d64 100644
--- a/src/Genocs.Core.Demo.WebApi/appsettings.json
+++ b/src/Genocs.Core.Demo.WebApi/appsettings.json
@@ -1,49 +1,96 @@
{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Information",
- "Microsoft": "Information",
- "Microsoft.Hosting.Lifetime": "Information"
+ "app": {
+ "name": "Demo WebApi",
+ "service": "Demo WebApi",
+ "instance": "1",
+ "version": "v1.0",
+ "displayBanner": true,
+ "displayVersion": true
+ },
+ "logger": {
+ "level": "debug",
+ "applicationName": "demo-service",
+ "excludePaths": [ "/ping", "/metrics" ],
+ "console": {
+ "enabled": true
+ },
+ "file": {
+ "enabled": true,
+ "path": "logs/logs.txt",
+ "interval": "day"
+ },
+ "azure": {
+ "enabled": false,
+ "connectionString": "<>"
}
},
- "AllowedHosts": "*",
- "ConnectionStrings": {
- "ApplicationInsights": ""
+ "monitoring": {
+ "jaeger": "localhost"
},
- "AppSettings": {
- "ServiceName": "Demo-WebApi"
+ "jwt": {
+ "ValidIssuer": "http://localhost/Auth",
+ "ValidAudience": "https://localhost:5000",
+ "Secret": ""
},
- "RabbitMQ": {
+ "_simmetric_jwt": {
+ "issuerSigningKey": "This is my custom Secret key for authentication S0M3RAN0MS3CR3T!1!MAG1C!1!",
+ "requireHttpsMetadata": false,
+ "saveToken": true,
+ "validateIssuerSigningKey": true,
+ "validateIssuer": false,
+ "validateLifetime": true,
+ "validateAudience": false,
+ "roleClaimType": "Role"
+ },
+ "rabbitMQ": {
"HostName": "localhost",
"VirtualHost": "/",
"UserName": "guest",
"Password": "guest"
},
- "AzureServiceBusTopic": {
+ "azureServiceBusTopic": {
"ConnectionString": "Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RMQ-xxxx;SharedAccessKey=xxxx",
"TopicName": "topic-name",
"SubscriptionName": "subscription-name"
},
- "AzureServiceBusQueue": {
+ "azureServiceBusQueue": {
"ConnectionString": "Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RMQ-xxxx;SharedAccessKey=xxxx",
"QueueName": "queue-name"
},
- "Mongo": {
- "ConnectionString": "mongodb://localhost",
- "Database": "demo"
- },
"mongodb": {
- "ConnectionString": "mongodb://localhost",
- "Database": "demo",
+ "connectionString": "mongodb://localhost:27017",
+ "database": "demo",
"enableTracing": true
},
- "jwt": {
- "ValidIssuer": "http://localhost/Auth",
- "ValidAudience": "https://localhost:5000",
- "Secret": "<<>>"
+ "azureKeyVault": {
+ "enabled": false,
+ "name": "kv-genocs"
+ },
+ "secrets": {
+ "Secret": "This is a secret coming from the appsettings.json file"
+ },
+ "httpClient": {
+ "type": "",
+ "retries": 2,
+ "services": {
+ "ca_issuer": "<<>>"
+ }
+ },
+ "externalService": {
+ "caller": "<<>>",
+ "public": "<<>>",
+ "private": "<<>>"
},
- "Monitoring": {
- "Jaeger": "localhost"
+ "swagger": {
+ "enabled": true,
+ "title": "Demo WebApi",
+ "description": "Demo WebApi",
+ "version": "v1",
+ "servers": [
+ {
+ "name": "Genocs",
+ "email": "giovanni.nocco@genocs.com"
+ }
+ ]
}
-}
\ No newline at end of file
+}
diff --git a/src/Genocs.Core.Demo.Worker/Consumers/SubmitOrderConsumer.cs b/src/Genocs.Core.Demo.Worker/Consumers/SubmitOrderConsumer.cs
index 00ad7730..9c320201 100644
--- a/src/Genocs.Core.Demo.Worker/Consumers/SubmitOrderConsumer.cs
+++ b/src/Genocs.Core.Demo.Worker/Consumers/SubmitOrderConsumer.cs
@@ -1,6 +1,6 @@
using Genocs.Core.Demo.Contracts;
using Genocs.Core.Demo.Domain.Aggregates;
-using Genocs.Persistence.MongoDb.Repositories;
+using Genocs.Persistence.MongoDb.Domain.Repositories;
using MassTransit;
namespace Genocs.Core.Demo.Worker.Consumers;
@@ -19,7 +19,7 @@ public SubmitOrderConsumer(ILogger logger, IMongoDbReposito
public async Task Consume(ConsumeContext context)
{
- Order order = new Order(context.Message.OrderId, context.Message.UserId, "", 1, "EUR");
+ Order order = new Order(context.Message.OrderId, context.Message.UserId, 1, "EUR");
await _orderRepository.InsertAsync(order);
_logger.LogInformation($"Order {context.Message.OrderId} processed!");
}
diff --git a/src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj b/src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj
index 5c94816b..f3eef8fe 100644
--- a/src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj
+++ b/src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj
@@ -1,36 +1,36 @@
-
- net7.0
- enable
- enable
- false
- false
- __genocs
- Linux
- ..\..
-
+
+ net8.0
+ false
+ false
+ __genocs
+ Linux
+ ..\..
+
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
diff --git a/src/Genocs.Core.Demo.Worker/MassTransitConsoleHostedService.cs b/src/Genocs.Core.Demo.Worker/MassTransitConsoleHostedService.cs
index 39f50b58..c38ea277 100644
--- a/src/Genocs.Core.Demo.Worker/MassTransitConsoleHostedService.cs
+++ b/src/Genocs.Core.Demo.Worker/MassTransitConsoleHostedService.cs
@@ -3,8 +3,9 @@
namespace Genocs.Core.Demo.Worker;
///
-/// General purpose worker. Please check the link below for further informations
+/// General purpose worker. Please check the link below for further information
/// https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-7.0&tabs=visual-studio
+/// .
///
public class MassTransitConsoleHostedService : IHostedService
{
@@ -20,14 +21,18 @@ public MassTransitConsoleHostedService(IBusControl bus, ILogger
{
- // Run the hosted service
+ // Run the hosted service
services.AddHostedService();
services
.AddGenocs(hostContext.Configuration)
+ .AddOpenTelemetry()
.AddMongoFast()
.RegisterMongoRepositories(Assembly.GetExecutingAssembly()); // It registers the repositories that has been overridden. No need in case of standard repository
ConfigureMassTransit(services, hostContext.Configuration);
- services.AddCustomOpenTelemetry(hostContext.Configuration);
})
.Build();
@@ -51,7 +44,6 @@
Log.CloseAndFlush();
-
static IServiceCollection ConfigureMassTransit(IServiceCollection services, IConfiguration configuration)
{
services.TryAddSingleton(KebabCaseEndpointNameFormatter.Instance);
@@ -75,7 +67,7 @@ static IServiceCollection RegisterCustomMongoRepository(IServiceCollection servi
static void ConfigureBus(IBusRegistrationContext context, IRabbitMqBusFactoryConfigurator configurator)
{
- //configurator.UseMessageData(new MongoDbMessageDataRepository("mongodb://127.0.0.1", "attachments"));
+ // configurator.UseMessageData(new MongoDbMessageDataRepository("mongodb://127.0.0.1", "attachments"));
//configurator.ReceiveEndpoint(KebabCaseEndpointNameFormatter.Instance.Consumer(), e =>
//{
@@ -99,7 +91,7 @@ static void ConfigureBus(IBusRegistrationContext context, IRabbitMqBusFactoryCon
static void ConfigureAzureServiceBusTopic(IServiceCollection services, IConfiguration configuration)
{
- services.Configure(configuration.GetSection(AzureServiceBusTopicSettings.Position));
+ services.Configure(configuration.GetSection(AzureServiceBusTopicOptions.Position));
services.AddSingleton();
@@ -107,12 +99,11 @@ static void ConfigureAzureServiceBusTopic(IServiceCollection services, IConfigur
var topicBus = services.BuildServiceProvider().GetRequiredService();
topicBus.Subscribe>();
-
}
static void ConfigureAzureServiceBusQueue(IServiceCollection services, IConfiguration configuration)
{
- services.Configure(configuration.GetSection(AzureServiceBusQueueSettings.Position));
+ services.Configure(configuration.GetSection(AzureServiceBusQueueOptions.Position));
services.AddSingleton();
diff --git a/src/Genocs.Core.Demo.Worker/appsettings.json b/src/Genocs.Core.Demo.Worker/appsettings.json
index 62530ab2..9ebf71e1 100644
--- a/src/Genocs.Core.Demo.Worker/appsettings.json
+++ b/src/Genocs.Core.Demo.Worker/appsettings.json
@@ -24,8 +24,8 @@
"QueueName": "queue-name"
},
"mongodb": {
- "ConnectionString": "mongodb://localhost",
- "Database": "demo",
+ "connectionString": "mongodb://localhost:27017",
+ "database": "demo",
"enableTracing": true
},
"Monitoring": {
@@ -87,7 +87,7 @@
"Token"
],
"console": {
- "enabled": true
+ "enabled": false
},
"elk": {
"enabled": false,
@@ -105,7 +105,7 @@
},
"azure": {
"enabled": false,
- "connectionString": ""
+ "connectionString": null
},
"tags": {}
},
diff --git a/src/Genocs.Core.UnitTests/Genocs.Core.UnitTests.csproj b/src/Genocs.Core.UnitTests/Genocs.Core.UnitTests.csproj
index 1603b78b..99505860 100644
--- a/src/Genocs.Core.UnitTests/Genocs.Core.UnitTests.csproj
+++ b/src/Genocs.Core.UnitTests/Genocs.Core.UnitTests.csproj
@@ -1,23 +1,22 @@
-
- net7.0
- enable
- enable
- false
- false
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
+
+ net8.0
+ false
+ false
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
\ No newline at end of file
diff --git a/src/Genocs.Core.UnitTests/UnitTest1.cs b/src/Genocs.Core.UnitTests/UnitTest1.cs
index aef15efe..44fa45bc 100644
--- a/src/Genocs.Core.UnitTests/UnitTest1.cs
+++ b/src/Genocs.Core.UnitTests/UnitTest1.cs
@@ -1,7 +1,7 @@
-namespace Genocs.Core.UnitTests;
-
using Xunit;
+namespace Genocs.Core.UnitTests;
+
public class UnitTest1
{
[Fact]
diff --git a/src/Genocs.Core/Builders/Extensions.cs b/src/Genocs.Core/Builders/Extensions.cs
index 790822de..72fa6c39 100644
--- a/src/Genocs.Core/Builders/Extensions.cs
+++ b/src/Genocs.Core/Builders/Extensions.cs
@@ -1,4 +1,4 @@
-using Genocs.Common.Options;
+using Genocs.Common.Configurations;
using Genocs.Common.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
@@ -6,57 +6,60 @@
namespace Genocs.Core.Builders;
-
///
-/// Builders Extensions
+/// Builders Extensions.
///
public static class Extensions
{
///
- /// The Builder
+ /// The Builder.
///
- ///
- ///
- ///
+ /// The service collection.
+ /// The configuration.
+ /// The builder.
public static IGenocsBuilder AddGenocs(this IServiceCollection services, IConfiguration? configuration = null)
{
var builder = GenocsBuilder.Create(services, configuration);
- var appOptions = builder.GetOptions(AppSettings.Position);
- services.AddSingleton(appOptions);
+ var settings = builder.GetOptions(AppOptions.Position);
+ services.AddSingleton(settings);
builder.Services.AddMemoryCache();
services.AddSingleton();
- if (!appOptions.DisplayBanner || string.IsNullOrWhiteSpace(appOptions.Name))
+ if (!settings.DisplayBanner || string.IsNullOrWhiteSpace(settings.Name))
{
return builder;
}
- var version = appOptions.DisplayVersion ? $" {appOptions.Version}" : string.Empty;
- Console.WriteLine(Figgle.FiggleFonts.Doom.Render($"{appOptions.Name}{version}"));
+
+ string version = settings.DisplayVersion ? $" {settings.Version}" : string.Empty;
+ Console.WriteLine(Figgle.FiggleFonts.Doom.Render(settings.Name + version));
+ ConsoleColor current = Console.ForegroundColor;
+ Console.ForegroundColor = ConsoleColor.Blue;
+ Console.WriteLine("Runtime Version: {0}", Environment.Version.ToString());
+ Console.ForegroundColor = current;
return builder;
}
///
- /// Run the application initializer
+ /// Run the application initializer.
///
- ///
- ///
+ /// The application builder.
+ /// The application builder.
public static IApplicationBuilder UseGenocs(this IApplicationBuilder app)
{
using var scope = app.ApplicationServices.CreateScope();
var initializer = scope.ServiceProvider.GetRequiredService();
Task.Run(() => initializer.InitializeAsync()).GetAwaiter().GetResult();
-
return app;
}
///
- /// Get option helper method
+ /// Get option helper method.
///
- ///
+ /// The option type parameter.
///
///
- ///
+ /// The option model or the default options.
public static TModel GetOptions(this IConfiguration configuration, string sectionName)
where TModel : new()
{
@@ -66,22 +69,22 @@ public static TModel GetOptions(this IConfiguration configuration, strin
}
///
- /// Get option helper method
+ /// Get option helper method.
///
- ///
- ///
- ///
- ///
- public static TModel GetOptions(this IGenocsBuilder builder, string settingsSectionName)
+ /// The option type parameter.
+ /// The builder.
+ /// The default section name.
+ /// The option.
+ public static TModel GetOptions(this IGenocsBuilder builder, string sectionName)
where TModel : new()
{
if (builder.Configuration != null)
{
- return builder.Configuration.GetOptions(settingsSectionName);
+ return builder.Configuration.GetOptions(sectionName);
}
using var serviceProvider = builder.Services.BuildServiceProvider();
var configuration = serviceProvider.GetRequiredService();
- return configuration.GetOptions(settingsSectionName);
+ return configuration.GetOptions(sectionName);
}
}
\ No newline at end of file
diff --git a/src/Genocs.Core/Builders/GenocsBuilder.cs b/src/Genocs.Core/Builders/GenocsBuilder.cs
index f3571e83..59c5b25b 100644
--- a/src/Genocs.Core/Builders/GenocsBuilder.cs
+++ b/src/Genocs.Core/Builders/GenocsBuilder.cs
@@ -1,14 +1,12 @@
-namespace Genocs.Core.Builders;
-
using Genocs.Common.Types;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using System;
using System.Collections.Concurrent;
-using System.Collections.Generic;
+
+namespace Genocs.Core.Builders;
///
-/// Genocs builder implementation
+/// Genocs builder implementation.
///
public sealed class GenocsBuilder : IGenocsBuilder
{
@@ -18,7 +16,7 @@ public sealed class GenocsBuilder : IGenocsBuilder
IServiceCollection IGenocsBuilder.Services => _services;
///
- /// The configuration
+ /// The configuration.
///
public IConfiguration? Configuration { get; }
@@ -33,7 +31,7 @@ private GenocsBuilder(IServiceCollection services, IConfiguration? configuration
public static IGenocsBuilder Create(IServiceCollection services, IConfiguration? configuration = null)
=> new GenocsBuilder(services, configuration);
- public bool TryRegister(string name)
+ public bool TryRegister(string name)
=> _registry.TryAdd(name, true);
public void AddBuildAction(Action execute)
@@ -46,7 +44,8 @@ public void AddInitializer(IInitializer initializer)
startupInitializer.AddInitializer(initializer);
});
- public void AddInitializer() where TInitializer : IInitializer
+ public void AddInitializer()
+ where TInitializer : IInitializer
=> AddBuildAction(sp =>
{
var initializer = sp.GetRequiredService();
diff --git a/src/Genocs.Core/Builders/IGenocsBuilder.cs b/src/Genocs.Core/Builders/IGenocsBuilder.cs
index 4775fe67..5ec0b17e 100644
--- a/src/Genocs.Core/Builders/IGenocsBuilder.cs
+++ b/src/Genocs.Core/Builders/IGenocsBuilder.cs
@@ -5,33 +5,37 @@
namespace Genocs.Core.Builders;
///
-/// The Application builder
+/// The Application builder.
///
public interface IGenocsBuilder
{
///
- /// Get the service collection
+ /// Get the service collection.
///
IServiceCollection Services { get; }
///
- /// Get the configuration
+ /// Get the configuration.
///
IConfiguration Configuration { get; }
///
- /// try to register a service by name
+ /// try to register a service by name.
///
- /// Name of the service trying to register
+ /// Name of the service trying to register.
///
bool TryRegister(string name);
///
- /// Build the actions based on the service provider
+ /// Build the actions based on the service provider.
///
///
void AddBuildAction(Action execute);
+
void AddInitializer(IInitializer initializer);
- void AddInitializer() where TInitializer : IInitializer;
+
+ void AddInitializer()
+ where TInitializer : IInitializer;
+
IServiceProvider Build();
}
\ No newline at end of file
diff --git a/src/Genocs.Core/Builders/IServiceId.cs b/src/Genocs.Core/Builders/IServiceId.cs
index 41eb29af..7fbec02a 100644
--- a/src/Genocs.Core/Builders/IServiceId.cs
+++ b/src/Genocs.Core/Builders/IServiceId.cs
@@ -1,12 +1,12 @@
namespace Genocs.Core.Builders;
///
-/// The ServiceId interface definition
+/// The ServiceId interface definition.
///
public interface IServiceId
{
///
- /// The id of the service as a getter
+ /// The id of the service as a getter.
///
string Id { get; }
}
\ No newline at end of file
diff --git a/src/Genocs.Core/Builders/ServiceId.cs b/src/Genocs.Core/Builders/ServiceId.cs
index 8a9742c8..6b2200f5 100644
--- a/src/Genocs.Core/Builders/ServiceId.cs
+++ b/src/Genocs.Core/Builders/ServiceId.cs
@@ -1,7 +1,5 @@
namespace Genocs.Core.Builders;
-using System;
-
internal class ServiceId : IServiceId
{
public string Id { get; } = $"{Guid.NewGuid():N}";
diff --git a/src/Genocs.Core/Builders/StartupInitializer.cs b/src/Genocs.Core/Builders/StartupInitializer.cs
index 5ec96c38..fdba6116 100644
--- a/src/Genocs.Core/Builders/StartupInitializer.cs
+++ b/src/Genocs.Core/Builders/StartupInitializer.cs
@@ -1,33 +1,33 @@
using Genocs.Common.Types;
+using Genocs.Core.Collections.Extensions;
namespace Genocs.Core.Builders;
///
-/// StartupInitializer implementation
+/// StartupInitializer implementation.
///
public class StartupInitializer : IStartupInitializer
{
private readonly IList _initializers = new List();
-
///
- /// Add new initializer if not present
+ /// Add new initializer if not present.
///
- ///
+ /// The initializer to be added.
public void AddInitializer(IInitializer initializer)
{
- if (initializer is null || _initializers.Contains(initializer))
+ if (initializer is null)
{
return;
}
- _initializers.Add(initializer);
+ _initializers.AddIfNotContains(initializer);
}
///
- /// Run the initializer
+ /// Run the initializer.
///
- ///
+ /// The task.
public async Task InitializeAsync()
{
foreach (var initializer in _initializers)
diff --git a/src/Genocs.Core/CQRS/Commands/Dispatchers/CommandDispatcher.cs b/src/Genocs.Core/CQRS/Commands/Dispatchers/CommandDispatcher.cs
index c5ae356a..86b1f6cf 100644
--- a/src/Genocs.Core/CQRS/Commands/Dispatchers/CommandDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Commands/Dispatchers/CommandDispatcher.cs
@@ -1,26 +1,22 @@
-namespace Genocs.Core.CQRS.Commands.Dispatchers
-{
- using Genocs.Core.CQRS.Commands;
- using Microsoft.Extensions.DependencyInjection;
- using System;
- using System.Threading;
- using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
- ///
- /// CommandDispatcher implementation
- ///
- internal sealed class CommandDispatcher : ICommandDispatcher
- {
- private readonly IServiceProvider _serviceProvider;
+namespace Genocs.Core.CQRS.Commands.Dispatchers;
- public CommandDispatcher(IServiceProvider serviceProvider)
- => _serviceProvider = serviceProvider;
+///
+/// CommandDispatcher implementation.
+///
+internal sealed class CommandDispatcher : ICommandDispatcher
+{
+ private readonly IServiceProvider _serviceProvider;
- public async Task SendAsync(T command, CancellationToken cancellationToken = default) where T : class, ICommand
- {
- await using var scope = _serviceProvider.CreateAsyncScope();
- var handler = scope.ServiceProvider.GetRequiredService>();
- await handler.HandleAsync(command, cancellationToken);
- }
+ public CommandDispatcher(IServiceProvider serviceProvider)
+ => _serviceProvider = serviceProvider;
+
+ public async Task SendAsync(T command, CancellationToken cancellationToken = default)
+ where T : class, ICommand
+ {
+ await using var scope = _serviceProvider.CreateAsyncScope();
+ var handler = scope.ServiceProvider.GetRequiredService>();
+ await handler.HandleAsync(command, cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Commands/Extensions.cs b/src/Genocs.Core/CQRS/Commands/Extensions.cs
index a9a15b37..84cc6b25 100644
--- a/src/Genocs.Core/CQRS/Commands/Extensions.cs
+++ b/src/Genocs.Core/CQRS/Commands/Extensions.cs
@@ -6,15 +6,15 @@
namespace Genocs.Core.CQRS.Commands;
///
-/// Extension method
+/// Extension methods.
///
public static class Extensions
{
///
- /// AddCommandHandlers
+ /// Add all the Command handlers to the DI container.
///
- ///
- ///
+ /// The builder.
+ /// The builder to be used for chaining pattern.
public static IGenocsBuilder AddCommandHandlers(this IGenocsBuilder builder)
{
builder.Services.Scan(s =>
@@ -28,14 +28,13 @@ public static IGenocsBuilder AddCommandHandlers(this IGenocsBuilder builder)
}
///
- /// AddInMemoryCommandDispatcher
+ /// Add the In Memory command dispatcher to the DI container.
///
- ///
- ///
+ /// The builder.
+ /// The builder to be used for chaining pattern.
public static IGenocsBuilder AddInMemoryCommandDispatcher(this IGenocsBuilder builder)
{
builder.Services.AddSingleton();
return builder;
-
}
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Commands/ICommand.cs b/src/Genocs.Core/CQRS/Commands/ICommand.cs
index 1e359e23..681357c7 100644
--- a/src/Genocs.Core/CQRS/Commands/ICommand.cs
+++ b/src/Genocs.Core/CQRS/Commands/ICommand.cs
@@ -1,9 +1,8 @@
-namespace Genocs.Core.CQRS.Commands
+namespace Genocs.Core.CQRS.Commands;
+
+///
+/// CQRS command interface.
+///
+public interface ICommand
{
- ///
- /// CQRS command interface
- ///
- public interface ICommand
- {
- }
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Commands/ICommandDispatcher.cs b/src/Genocs.Core/CQRS/Commands/ICommandDispatcher.cs
index 4b8076c6..ccb7d157 100644
--- a/src/Genocs.Core/CQRS/Commands/ICommandDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Commands/ICommandDispatcher.cs
@@ -1,20 +1,17 @@
-namespace Genocs.Core.CQRS.Commands
-{
- using System.Threading;
- using System.Threading.Tasks;
+namespace Genocs.Core.CQRS.Commands;
+///
+/// Command dispatcher interface.
+///
+public interface ICommandDispatcher
+{
///
- /// Command dispatcher interface
+ /// SendAsync.
///
- public interface ICommandDispatcher
- {
- ///
- /// SendAsync
- ///
- ///
- ///
- ///
- ///
- Task SendAsync(T command, CancellationToken cancellationToken = default) where T : class, ICommand;
- }
+ /// The type of command.
+ /// The command object.
+ /// The cancellation token.
+ /// The task.
+ Task SendAsync(T command, CancellationToken cancellationToken = default)
+ where T : class, ICommand;
}
diff --git a/src/Genocs.Core/CQRS/Commands/ICommandHandler.cs b/src/Genocs.Core/CQRS/Commands/ICommandHandler.cs
index 6c5f9c61..7e90ec19 100644
--- a/src/Genocs.Core/CQRS/Commands/ICommandHandler.cs
+++ b/src/Genocs.Core/CQRS/Commands/ICommandHandler.cs
@@ -1,34 +1,32 @@
namespace Genocs.Core.CQRS.Commands;
-using System.Threading;
-using System.Threading.Tasks;
-
///
-/// CQRS command handler interface
+/// CQRS command handler interface.
///
-///
-public interface ICommandHandler where TCommand : class, ICommand
+/// The type of command.
+public interface ICommandHandler
+ where TCommand : class, ICommand
{
///
- /// HandleAsync
+ /// HandleAsync.
///
- ///
- ///
- ///
+ /// The command
+ /// The Cancellation token.
+ /// Async Task.
Task HandleAsync(TCommand command, CancellationToken cancellationToken = default);
}
-
///
-/// Legacy CQRS command handler interface
+/// Legacy CQRS command handler interface.
///
-///
-public interface ICommandHandlerLegacy where T : ICommand
+/// The type of command.
+public interface ICommandHandlerLegacy
+ where T : ICommand
{
///
- /// Legacy HandleAsync
+ /// Legacy HandleAsync.
///
- ///
- ///
+ /// The command.
+ /// Async Task.
Task HandleCommand(T @command);
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Commons/Extensions.cs b/src/Genocs.Core/CQRS/Commons/Extensions.cs
index 88cd514e..014e8e6c 100644
--- a/src/Genocs.Core/CQRS/Commons/Extensions.cs
+++ b/src/Genocs.Core/CQRS/Commons/Extensions.cs
@@ -10,20 +10,20 @@
namespace Genocs.Core.CQRS.Commons;
///
-/// Extension helper to handle the whole set of Dispatcher
+/// Extension helper to handle the whole set of Dispatcher.
///
public static class Extensions
{
///
- /// AddHandlers implementation
+ /// AddHandlers implementation.
///
- ///
- ///
+ /// The service collection.
+ /// Name of the project.
///
public static IServiceCollection AddHandlers(this IServiceCollection services, string project)
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies()
- .Where(x => x.FullName != null && x.FullName.Contains(project))
+ .Where(x => x.FullName != null && x.FullName.Contains(project))
.ToArray();
services.Scan(s => s.FromAssemblies(assemblies)
@@ -48,10 +48,10 @@ public static IServiceCollection AddHandlers(this IServiceCollection services, s
}
///
- /// AddDispatchers Implementation
+ /// AddDispatchers Implementation.
///
- ///
- ///
+ /// The service collection.
+ /// The service collection to be used for chaining pattern.
public static IServiceCollection AddDispatchers(this IServiceCollection services)
=> services
.AddSingleton()
diff --git a/src/Genocs.Core/CQRS/Commons/IDispatcher.cs b/src/Genocs.Core/CQRS/Commons/IDispatcher.cs
index fbdec5fa..4df4070f 100644
--- a/src/Genocs.Core/CQRS/Commons/IDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Commons/IDispatcher.cs
@@ -1,41 +1,40 @@
-namespace Genocs.Core.CQRS.Commons
-{
- using Genocs.Core.CQRS.Commands;
- using Genocs.Core.CQRS.Events;
- using Genocs.Core.CQRS.Queries;
- using System.Threading;
- using System.Threading.Tasks;
+using Genocs.Core.CQRS.Commands;
+using Genocs.Core.CQRS.Events;
+using Genocs.Core.CQRS.Queries;
+
+namespace Genocs.Core.CQRS.Commons;
+///
+/// Generic dispatcher interface.
+///
+public interface IDispatcher
+{
///
- /// Generic dispatcher interface
+ /// Generic command sender.
///
- public interface IDispatcher
- {
- ///
- /// Generic command sender
- ///
- ///
- ///
- ///
- ///
- Task SendAsync(T command, CancellationToken cancellationToken = default) where T : class, ICommand;
+ ///
+ ///
+ ///
+ ///
+ Task SendAsync(T command, CancellationToken cancellationToken = default)
+ where T : class, ICommand;
- ///
- /// Generic event publisher
- ///
- ///
- ///
- ///
- ///
- Task PublishAsync(T @event, CancellationToken cancellationToken = default) where T : class, IEvent;
+ ///
+ /// Generic event publisher.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task PublishAsync(T @event, CancellationToken cancellationToken = default)
+ where T : class, IEvent;
- ///
- /// Generic query fetcher
- ///
- ///
- ///
- ///
- ///
- Task QueryAsync(IQuery query, CancellationToken cancellationToken = default);
- }
+ ///
+ /// Generic query fetcher.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task QueryAsync(IQuery query, CancellationToken cancellationToken = default);
}
diff --git a/src/Genocs.Core/CQRS/Commons/InMemoryDispatcher.cs b/src/Genocs.Core/CQRS/Commons/InMemoryDispatcher.cs
index c3c872ca..609ac04f 100644
--- a/src/Genocs.Core/CQRS/Commons/InMemoryDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Commons/InMemoryDispatcher.cs
@@ -1,14 +1,11 @@
-namespace Genocs.Core.CQRS.Commons;
-
-using Genocs.Core.CQRS.Commands;
+using Genocs.Core.CQRS.Commands;
using Genocs.Core.CQRS.Events;
using Genocs.Core.CQRS.Queries;
-using System.Threading;
-using System.Threading.Tasks;
+namespace Genocs.Core.CQRS.Commons;
///
-/// The class name will be renamed!!!
+/// The class name will be renamed.
///
internal sealed class InMemoryDispatcher : IDispatcher
{
@@ -16,18 +13,22 @@ internal sealed class InMemoryDispatcher : IDispatcher
private readonly IEventDispatcher _eventDispatcher;
private readonly IQueryDispatcher _queryDispatcher;
- public InMemoryDispatcher(ICommandDispatcher commandDispatcher, IEventDispatcher eventDispatcher,
- IQueryDispatcher queryDispatcher)
+ public InMemoryDispatcher(
+ ICommandDispatcher commandDispatcher,
+ IEventDispatcher eventDispatcher,
+ IQueryDispatcher queryDispatcher)
{
- _commandDispatcher = commandDispatcher;
- _eventDispatcher = eventDispatcher;
- _queryDispatcher = queryDispatcher;
+ _commandDispatcher = commandDispatcher ?? throw new ArgumentNullException(nameof(commandDispatcher));
+ _eventDispatcher = eventDispatcher ?? throw new ArgumentNullException(nameof(eventDispatcher));
+ _queryDispatcher = queryDispatcher ?? throw new ArgumentNullException(nameof(queryDispatcher));
}
- public Task SendAsync(T command, CancellationToken cancellationToken = default) where T : class, ICommand
+ public Task SendAsync(T command, CancellationToken cancellationToken = default)
+ where T : class, ICommand
=> _commandDispatcher.SendAsync(command, cancellationToken);
- public Task PublishAsync(T @event, CancellationToken cancellationToken = default) where T : class, IEvent
+ public Task PublishAsync(T @event, CancellationToken cancellationToken = default)
+ where T : class, IEvent
=> _eventDispatcher.PublishAsync(@event, cancellationToken);
public Task QueryAsync(IQuery query, CancellationToken cancellationToken = default)
diff --git a/src/Genocs.Core/CQRS/Events/Dispatchers/EventDispatcher.cs b/src/Genocs.Core/CQRS/Events/Dispatchers/EventDispatcher.cs
index edccd1cb..cdea3890 100644
--- a/src/Genocs.Core/CQRS/Events/Dispatchers/EventDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Events/Dispatchers/EventDispatcher.cs
@@ -1,20 +1,31 @@
-namespace Genocs.Core.CQRS.Events.Dispatchers;
-
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Genocs.Core.CQRS.Events;
using Microsoft.Extensions.DependencyInjection;
+namespace Genocs.Core.CQRS.Events.Dispatchers;
+
+///
+/// The event dispatcher is responsible for dispatching events to their respective handlers.
+///
internal sealed class EventDispatcher : IEventDispatcher
{
private readonly IServiceProvider _serviceProvider;
+ ///
+ /// standard constructor.
+ ///
+ /// The service provider.
public EventDispatcher(IServiceProvider serviceProvider)
=> _serviceProvider = serviceProvider;
- public async Task PublishAsync(T @event, CancellationToken cancellationToken = default) where T : class, IEvent
+ ///
+ /// The event dispatcher is responsible for dispatching events to their respective handlers.
+ ///
+ /// The type of the event to publish.
+ /// The event object instance.
+ /// The cancellation token.
+ /// The event cannot be null.
+ /// Async task.
+ public async Task PublishAsync(T @event, CancellationToken cancellationToken = default)
+ where T : class, IEvent
{
if (@event is null)
{
diff --git a/src/Genocs.Core/CQRS/Events/Extensions.cs b/src/Genocs.Core/CQRS/Events/Extensions.cs
index b845280b..db9d35dc 100644
--- a/src/Genocs.Core/CQRS/Events/Extensions.cs
+++ b/src/Genocs.Core/CQRS/Events/Extensions.cs
@@ -6,12 +6,12 @@
namespace Genocs.Core.CQRS.Events;
///
-/// CQRS events extensions
+/// CQRS events extensions.
///
public static class Extensions
{
///
- /// AddEventHandlers
+ /// AddEventHandlers.
///
///
///
@@ -29,7 +29,7 @@ public static IGenocsBuilder AddEventHandlers(this IGenocsBuilder builder)
///
- /// AddInMemoryEventDispatcher
+ /// AddInMemoryEventDispatcher.
///
///
///
@@ -40,7 +40,7 @@ public static IGenocsBuilder AddInMemoryEventDispatcher(this IGenocsBuilder buil
}
///
- /// AddEventHandlers
+ /// AddEventHandlers.
///
///
///
@@ -57,7 +57,7 @@ public static IServiceCollection AddEventHandlers(this IServiceCollection servic
}
///
- /// AddInMemoryEventDispatcher
+ /// AddInMemoryEventDispatcher.
///
///
///
diff --git a/src/Genocs.Core/CQRS/Events/IEvent.cs b/src/Genocs.Core/CQRS/Events/IEvent.cs
index 4ea82680..c61433d7 100644
--- a/src/Genocs.Core/CQRS/Events/IEvent.cs
+++ b/src/Genocs.Core/CQRS/Events/IEvent.cs
@@ -1,7 +1,7 @@
namespace Genocs.Core.CQRS.Events;
///
-/// The CQRS event interface that defines a generic event used for integration tasks
+/// The CQRS event interface that defines a generic event used for integration tasks.
///
public interface IEvent
{
diff --git a/src/Genocs.Core/CQRS/Events/IEventDispatcher.cs b/src/Genocs.Core/CQRS/Events/IEventDispatcher.cs
index 3b3d7b20..9d9ae905 100644
--- a/src/Genocs.Core/CQRS/Events/IEventDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Events/IEventDispatcher.cs
@@ -1,19 +1,17 @@
namespace Genocs.Core.CQRS.Events;
-using System.Threading;
-using System.Threading.Tasks;
-
///
-/// The CQRS event dispatcher interface used to publish an integration event
+/// The CQRS event dispatcher interface used to publish an integration event.
///
public interface IEventDispatcher
{
///
- /// It allows to Publish an integration event Async
+ /// It allows to Publish an integration event Async.
///
- ///
+ /// The Type of the event.
///
///
///
- Task PublishAsync(T @event, CancellationToken cancellationToken = default) where T : class, IEvent;
+ Task PublishAsync(T @event, CancellationToken cancellationToken = default)
+ where T : class, IEvent;
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Events/IEventHandler.cs b/src/Genocs.Core/CQRS/Events/IEventHandler.cs
index f636e7fb..cf03ffbc 100644
--- a/src/Genocs.Core/CQRS/Events/IEventHandler.cs
+++ b/src/Genocs.Core/CQRS/Events/IEventHandler.cs
@@ -1,13 +1,11 @@
namespace Genocs.Core.CQRS.Events;
-using System.Threading;
-using System.Threading.Tasks;
-
///
-/// Generic interface for CQRS Event handler
+/// Generic interface for CQRS Event handler.
///
///
-public interface IEventHandler where TEvent : class, IEvent
+public interface IEventHandler
+ where TEvent : class, IEvent
{
///
/// Standard Event handler
@@ -18,15 +16,15 @@ public interface IEventHandler where TEvent : class, IEvent
Task HandleAsync(TEvent @event, CancellationToken cancellationToken = default);
}
-
///
-/// Legacy Event handler interface definition
+/// Legacy Event handler interface definition.
///
///
-public interface IEventHandlerLegacy where T : IEvent
+public interface IEventHandlerLegacy
+ where T : IEvent
{
///
- /// Legacy event handler place holder
+ /// Legacy event handler place holder.
///
///
///
diff --git a/src/Genocs.Core/CQRS/Events/IRejectedEvent.cs b/src/Genocs.Core/CQRS/Events/IRejectedEvent.cs
index 22e1f9e0..9fbae293 100644
--- a/src/Genocs.Core/CQRS/Events/IRejectedEvent.cs
+++ b/src/Genocs.Core/CQRS/Events/IRejectedEvent.cs
@@ -1,8 +1,7 @@
-namespace Genocs.Core.CQRS.Events
+namespace Genocs.Core.CQRS.Events;
+
+public interface IRejectedEvent : IEvent
{
- public interface IRejectedEvent : IEvent
- {
- string Reason { get; }
- string Code { get; }
- }
+ string Reason { get; }
+ string Code { get; }
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Events/RejectedEvent.cs b/src/Genocs.Core/CQRS/Events/RejectedEvent.cs
index 11109941..7d2f82d4 100644
--- a/src/Genocs.Core/CQRS/Events/RejectedEvent.cs
+++ b/src/Genocs.Core/CQRS/Events/RejectedEvent.cs
@@ -1,21 +1,19 @@
-namespace Genocs.Core.CQRS.Events
-{
- using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
- public class RejectedEvent : IRejectedEvent
- {
- public string Reason { get; }
- public string Code { get; }
+namespace Genocs.Core.CQRS.Events;
- [JsonConstructor]
- public RejectedEvent(string reason, string code)
- {
- Reason = reason;
- Code = code;
- }
+public class RejectedEvent : IRejectedEvent
+{
+ public string Reason { get; }
+ public string Code { get; }
- public static IRejectedEvent For(string name)
- => new RejectedEvent($"There was an error when executing: " +
- $"{name}", $"{name}_error");
+ [JsonConstructor]
+ public RejectedEvent(string reason, string code)
+ {
+ Reason = reason;
+ Code = code;
}
+
+ public static IRejectedEvent For(string name)
+ => new RejectedEvent($"There was an error when executing: " + $"{name}", $"{name}_error");
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/Dispatchers/QueryDispatcher.cs b/src/Genocs.Core/CQRS/Queries/Dispatchers/QueryDispatcher.cs
index 999262df..4e1fadd5 100644
--- a/src/Genocs.Core/CQRS/Queries/Dispatchers/QueryDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Queries/Dispatchers/QueryDispatcher.cs
@@ -1,46 +1,42 @@
-namespace Genocs.Core.CQRS.Queries.Dispatchers
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Genocs.Core.CQRS.Queries.Dispatchers;
+
+internal sealed class QueryDispatcher : IQueryDispatcher
{
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- using Microsoft.Extensions.DependencyInjection;
+ private readonly IServiceProvider _serviceProvider;
- internal sealed class QueryDispatcher : IQueryDispatcher
+ public QueryDispatcher(IServiceProvider serviceProvider)
{
- private readonly IServiceProvider _serviceProvider;
+ _serviceProvider = serviceProvider;
+ }
- public QueryDispatcher(IServiceProvider serviceProvider)
+ public async Task QueryAsync(IQuery query, CancellationToken cancellationToken = default)
+ {
+ if (query is null)
{
- _serviceProvider = serviceProvider;
+ throw new InvalidOperationException("Query cannot be null.");
}
- public async Task QueryAsync(IQuery query, CancellationToken cancellationToken = default)
- {
- if (query is null)
- {
- throw new InvalidOperationException("Query cannot be null.");
- }
-
- await using var scope = _serviceProvider.CreateAsyncScope();
- var handlerType = typeof(IQueryHandler<,>).MakeGenericType(query.GetType(), typeof(TResult));
- var handler = scope.ServiceProvider.GetRequiredService(handlerType);
+ await using var scope = _serviceProvider.CreateAsyncScope();
+ var handlerType = typeof(IQueryHandler<,>).MakeGenericType(query.GetType(), typeof(TResult));
+ object handler = scope.ServiceProvider.GetRequiredService(handlerType);
- var method = handlerType.GetMethod(nameof(IQueryHandler, TResult>.HandleAsync));
- if (method is null)
- {
- throw new InvalidOperationException($"Query handler for '{typeof(TResult).Name}' is invalid.");
- }
+ var method = handlerType.GetMethod(nameof(IQueryHandler, TResult>.HandleAsync));
+ if (method is null)
+ {
+ throw new InvalidOperationException($"Query handler for '{typeof(TResult).Name}' is invalid.");
+ }
- return await (Task)method.Invoke(handler, new object[] { query, cancellationToken });
+ return await (Task)method.Invoke(handler, new object[] { query, cancellationToken });
- }
+ }
- public async Task QueryAsync(TQuery query, CancellationToken cancellationToken = default)
- where TQuery : class, IQuery
- {
- using var scope = _serviceProvider.CreateScope();
- var handler = scope.ServiceProvider.GetRequiredService>();
- return await handler.HandleAsync(query, cancellationToken);
- }
+ public async Task QueryAsync(TQuery query, CancellationToken cancellationToken = default)
+ where TQuery : class, IQuery
+ {
+ using var scope = _serviceProvider.CreateScope();
+ var handler = scope.ServiceProvider.GetRequiredService>();
+ return await handler.HandleAsync(query, cancellationToken);
}
}
diff --git a/src/Genocs.Core/CQRS/Queries/Extensions.cs b/src/Genocs.Core/CQRS/Queries/Extensions.cs
index aa026f06..16024689 100644
--- a/src/Genocs.Core/CQRS/Queries/Extensions.cs
+++ b/src/Genocs.Core/CQRS/Queries/Extensions.cs
@@ -6,12 +6,12 @@
namespace Genocs.Core.CQRS.Queries;
///
-///
+/// Extension helper class for CQRS Queries.
///
public static class Extensions
{
///
- /// AddQueryHandlers
+ /// AddQueryHandlers.
///
///
///
@@ -28,7 +28,7 @@ public static IGenocsBuilder AddQueryHandlers(this IGenocsBuilder builder)
}
///
- /// AddInMemoryQueryDispatcher
+ /// AddInMemoryQueryDispatcher.
///
///
///
diff --git a/src/Genocs.Core/CQRS/Queries/IPagedFilter.cs b/src/Genocs.Core/CQRS/Queries/IPagedFilter.cs
index 72ea7a99..5e117797 100644
--- a/src/Genocs.Core/CQRS/Queries/IPagedFilter.cs
+++ b/src/Genocs.Core/CQRS/Queries/IPagedFilter.cs
@@ -1,20 +1,18 @@
-namespace Genocs.Core.CQRS.Queries
-{
- using System.Collections.Generic;
+namespace Genocs.Core.CQRS.Queries;
+///
+/// The paged filter interface.
+///
+///
+///
+public interface IPagedFilter
+ where TQuery : IQuery
+{
///
- /// The paged filter interface
+ /// Filter.
///
- ///
- ///
- public interface IPagedFilter where TQuery : IQuery
- {
- ///
- /// Filter
- ///
- ///
- ///
- ///
- PagedResult Filter(IEnumerable values, TQuery query);
- }
+ ///
+ ///
+ ///
+ PagedResult Filter(IEnumerable values, TQuery query);
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/IPagedQuery.cs b/src/Genocs.Core/CQRS/Queries/IPagedQuery.cs
index d8b9f5e1..ffd6fd89 100644
--- a/src/Genocs.Core/CQRS/Queries/IPagedQuery.cs
+++ b/src/Genocs.Core/CQRS/Queries/IPagedQuery.cs
@@ -1,28 +1,27 @@
-namespace Genocs.Core.CQRS.Queries
+namespace Genocs.Core.CQRS.Queries;
+
+///
+/// Query for pagination.
+///
+public interface IPagedQuery : IQuery
{
///
- /// Query for pagination
+ /// Page to query zero indexed.
///
- public interface IPagedQuery : IQuery
- {
- ///
- /// Page to query zero indexed
- ///
- int Page { get; }
+ int Page { get; }
- ///
- /// Number of results. Aka page size
- ///
- int Results { get; }
+ ///
+ /// Number of results. Aka page size.
+ ///
+ int Results { get; }
- ///
- /// The field used to order by
- ///
- string? OrderBy { get; }
+ ///
+ /// The field used to order by.
+ ///
+ string? OrderBy { get; }
- ///
- /// Type of order. It could be ASC or DESC
- ///
- string? SortOrder { get; }
- }
+ ///
+ /// Type of order. It could be ASC or DESC.
+ ///
+ string? SortOrder { get; }
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/IQuery.cs b/src/Genocs.Core/CQRS/Queries/IQuery.cs
index 4b0cfd95..ba1ea122 100644
--- a/src/Genocs.Core/CQRS/Queries/IQuery.cs
+++ b/src/Genocs.Core/CQRS/Queries/IQuery.cs
@@ -1,17 +1,16 @@
-namespace Genocs.Core.CQRS.Queries
+namespace Genocs.Core.CQRS.Queries;
+
+///
+/// Generic interface for query.
+///
+public interface IQuery
{
- ///
- /// Generic interface for query.
- ///
- public interface IQuery
- {
- }
+}
- ///
- /// Generic interface for type
- ///
- ///
- public interface IQuery : IQuery
- {
- }
+///
+/// Generic interface for type.
+///
+///
+public interface IQuery : IQuery
+{
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/IQueryDispatcher.cs b/src/Genocs.Core/CQRS/Queries/IQueryDispatcher.cs
index eb5f3ca5..b3ee53eb 100644
--- a/src/Genocs.Core/CQRS/Queries/IQueryDispatcher.cs
+++ b/src/Genocs.Core/CQRS/Queries/IQueryDispatcher.cs
@@ -1,31 +1,27 @@
-namespace Genocs.Core.CQRS.Queries
-{
- using System.Threading.Tasks;
- using System.Threading;
+namespace Genocs.Core.CQRS.Queries;
+///
+/// The query dispatcher interface.
+///
+public interface IQueryDispatcher
+{
///
- /// The query dispatcher interface
+ /// QueryAsync.
///
- public interface IQueryDispatcher
- {
- ///
- /// QueryAsync
- ///
- ///
- ///
- ///
- ///
- Task QueryAsync(IQuery query, CancellationToken cancellationToken = default);
+ /// The result type.
+ /// The query.
+ /// The Cancellation token.
+ /// The query result.
+ Task QueryAsync(IQuery query, CancellationToken cancellationToken = default);
- ///
- /// QueryAsync
- ///
- ///
- ///
- ///
- ///
- ///
- Task QueryAsync(TQuery query, CancellationToken cancellationToken = default)
- where TQuery : class, IQuery;
- }
+ ///
+ /// QueryAsync.
+ ///
+ /// The type of the query.
+ /// The result.
+ /// The query object instance.
+ /// The cancellation token.
+ /// The query result.
+ Task QueryAsync(TQuery query, CancellationToken cancellationToken = default)
+ where TQuery : class, IQuery;
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/IQueryHandler.cs b/src/Genocs.Core/CQRS/Queries/IQueryHandler.cs
index f05d4858..9c3f30e8 100644
--- a/src/Genocs.Core/CQRS/Queries/IQueryHandler.cs
+++ b/src/Genocs.Core/CQRS/Queries/IQueryHandler.cs
@@ -1,21 +1,21 @@
-namespace Genocs.Core.CQRS.Queries
-{
- using System.Threading.Tasks;
- using System.Threading;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace Genocs.Core.CQRS.Queries;
+///
+/// The query handler interface.
+///
+///
+///
+public interface IQueryHandler
+ where TQuery : class, IQuery
+{
///
- /// The query handler interface
+ /// HandleAsync.
///
- ///
- ///
- public interface IQueryHandler where TQuery : class, IQuery
- {
- ///
- /// HandleAsync
- ///
- ///
- ///
- ///
- Task HandleAsync(TQuery query, CancellationToken cancellationToken = default);
- }
+ ///
+ ///
+ ///
+ Task HandleAsync(TQuery query, CancellationToken cancellationToken = default);
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/PagedQueryBase.cs b/src/Genocs.Core/CQRS/Queries/PagedQueryBase.cs
index 43e90b9f..f518a21e 100644
--- a/src/Genocs.Core/CQRS/Queries/PagedQueryBase.cs
+++ b/src/Genocs.Core/CQRS/Queries/PagedQueryBase.cs
@@ -1,28 +1,27 @@
-namespace Genocs.Core.CQRS.Queries
+namespace Genocs.Core.CQRS.Queries;
+
+///
+/// The paged query result.
+///
+public abstract class PagedQueryBase : IPagedQuery
{
///
- /// The paged query result
+ /// The zero based page index.
///
- public abstract class PagedQueryBase : IPagedQuery
- {
- ///
- /// The zero based page index
- ///
- public int Page { get; set; }
+ public int Page { get; set; }
- ///
- /// Number of results. Aka page size
- ///
- public int Results { get; set; }
+ ///
+ /// Number of results. Aka page size.
+ ///
+ public int Results { get; set; }
- ///
- /// The field used to order by
- ///
- public string? OrderBy { get; set; }
+ ///
+ /// The field used to order by.
+ ///
+ public string? OrderBy { get; set; }
- ///
- /// Type of order. It could be ASC or DESC
- ///
- public string? SortOrder { get; set; }
- }
+ ///
+ /// Type of order. It could be ASC or DESC.
+ ///
+ public string? SortOrder { get; set; }
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/PagedQueryWithFilter.cs b/src/Genocs.Core/CQRS/Queries/PagedQueryWithFilter.cs
index 2c4ebac3..03fdaf18 100644
--- a/src/Genocs.Core/CQRS/Queries/PagedQueryWithFilter.cs
+++ b/src/Genocs.Core/CQRS/Queries/PagedQueryWithFilter.cs
@@ -1,13 +1,12 @@
-namespace Genocs.Core.CQRS.Queries
+namespace Genocs.Core.CQRS.Queries;
+
+///
+/// Paged query extension with Filter.
+///
+public class PagedQueryWithFilter : PagedQueryBase
{
///
- /// Paged query extension with Filter
+ /// The filter.
///
- public class PagedQueryWithFilter : PagedQueryBase
- {
- ///
- /// The filter
- ///
- public string FilterBy { get; set; } = string.Empty;
- }
+ public string FilterBy { get; set; } = string.Empty;
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/PagedResult.cs b/src/Genocs.Core/CQRS/Queries/PagedResult.cs
index be31ae0f..e501d3ae 100644
--- a/src/Genocs.Core/CQRS/Queries/PagedResult.cs
+++ b/src/Genocs.Core/CQRS/Queries/PagedResult.cs
@@ -1,74 +1,82 @@
-namespace Genocs.Core.CQRS.Queries
+using System.Text.Json.Serialization;
+
+namespace Genocs.Core.CQRS.Queries;
+
+///
+/// The paged result.
+///
+/// The page result type.
+public class PagedResult : PagedResultBase
{
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json.Serialization;
+ ///
+ /// Returned items.
+ ///
+ public IEnumerable Items { get; }
///
- /// The paged result
+ /// Default constructor.
///
- ///
- public class PagedResult : PagedResultBase
+ protected PagedResult()
{
- ///
- /// Returned items
- ///
- public IEnumerable Items { get; }
-
- ///
- /// Default constructor
- ///
- protected PagedResult()
- {
- Items = Enumerable.Empty();
- }
+ Items = Enumerable.Empty();
+ }
- ///
- /// Standard constructor
- ///
- ///
- ///
- ///
- ///
- ///
- [JsonConstructor]
- protected PagedResult(IEnumerable items,
- int currentPage,
- int resultsPerPage,
- int totalPages,
- long totalResults) :
- base(currentPage, resultsPerPage, totalPages, totalResults)
- {
- Items = items;
- }
+ ///
+ /// Standard constructor.
+ ///
+ /// The list of items.
+ /// Zero based current page.
+ /// Number of results within the page.
+ /// Total number of pages.
+ /// Total number of results.
+ [JsonConstructor]
+ protected PagedResult(
+ IEnumerable items,
+ int currentPage,
+ int resultsPerPage,
+ int totalPages,
+ long totalResults)
+ : base(currentPage, resultsPerPage, totalPages, totalResults)
+ {
+ Items = items;
+ }
- ///
- /// Create helper
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static PagedResult Create(IEnumerable items,
- int currentPage, int resultsPerPage,
- int totalPages, long totalResults)
- => new PagedResult(items, currentPage, resultsPerPage, totalPages, totalResults);
+ ///
+ /// Create helper.
+ ///
+ /// The list of items.
+ /// Zero based current page.
+ /// Number of results within the page.
+ /// Total number of pages.
+ /// Total number of results.
+ /// The paged results.
+ public static PagedResult Create(
+ IEnumerable items,
+ int currentPage,
+ int resultsPerPage,
+ int totalPages,
+ long totalResults)
+ => new(items, currentPage, resultsPerPage, totalPages, totalResults);
- ///
- /// From helper
- ///
- ///
- ///
- ///
- public static PagedResult From(PagedResultBase result, IEnumerable items)
- => new PagedResult(items, result.CurrentPage, result.ResultsPerPage,
- result.TotalPages, result.TotalResults);
+ ///
+ /// From helper.
+ ///
+ ///
+ ///
+ ///
+ public static PagedResult From(
+ PagedResultBase result,
+ IEnumerable items)
+ => new(
+ items,
+ result.CurrentPage,
+ result.ResultsPerPage,
+ result.TotalPages,
+ result.TotalResults);
- ///
- /// Static helper to get Empty result
- ///
- public static PagedResult Empty => new PagedResult();
- }
+ ///
+ /// Static helper to get Empty result.
+ ///
+ public static PagedResult Empty
+ => new();
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/PagedResultBase.cs b/src/Genocs.Core/CQRS/Queries/PagedResultBase.cs
index 79dec7f1..b9a8a5e2 100644
--- a/src/Genocs.Core/CQRS/Queries/PagedResultBase.cs
+++ b/src/Genocs.Core/CQRS/Queries/PagedResultBase.cs
@@ -1,51 +1,49 @@
-namespace Genocs.Core.CQRS.Queries
+namespace Genocs.Core.CQRS.Queries;
+
+///
+/// The page result base class.
+///
+public abstract class PagedResultBase
{
///
- /// The page result base class
+ /// Returned zero index page.
///
- public abstract class PagedResultBase
- {
- ///
- /// Returned zero index page
- ///
- public int CurrentPage { get; }
+ public int CurrentPage { get; }
- ///
- /// Number of returned results. Aka page size
- ///
- public int ResultsPerPage { get; }
+ ///
+ /// Number of returned results. Aka page size.
+ ///
+ public int ResultsPerPage { get; }
- ///
- /// Number of pages
- ///
- public int TotalPages { get; }
+ ///
+ /// Number of pages.
+ ///
+ public int TotalPages { get; }
- ///
- /// Total number of results
- ///
- public long TotalResults { get; }
+ ///
+ /// Total number of results.
+ ///
+ public long TotalResults { get; }
- ///
- /// Default constructor
- ///
- protected PagedResultBase()
- {
- }
+ ///
+ /// Default constructor.
+ ///
+ protected PagedResultBase()
+ {
+ }
- ///
- /// Standard constructor
- ///
- ///
- ///
- ///
- ///
- protected PagedResultBase(int currentPage, int resultsPerPage,
- int totalPages, long totalResults)
- {
- CurrentPage = currentPage > totalPages ? totalPages : currentPage;
- ResultsPerPage = resultsPerPage;
- TotalPages = totalPages;
- TotalResults = totalResults;
- }
+ ///
+ /// Standard constructor.
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected PagedResultBase(int currentPage, int resultsPerPage, int totalPages, long totalResults)
+ {
+ CurrentPage = currentPage > totalPages ? totalPages : currentPage;
+ ResultsPerPage = resultsPerPage;
+ TotalPages = totalPages;
+ TotalResults = totalResults;
}
}
\ No newline at end of file
diff --git a/src/Genocs.Core/CQRS/Queries/Request.cs b/src/Genocs.Core/CQRS/Queries/Request.cs
index 97ddc21d..08c620d8 100644
--- a/src/Genocs.Core/CQRS/Queries/Request.cs
+++ b/src/Genocs.Core/CQRS/Queries/Request.cs
@@ -1,16 +1,15 @@
-namespace Genocs.Core.CQRS.Queries
+namespace Genocs.Core.CQRS.Queries;
+
+public interface ISearchRequest
{
- public interface ISearchRequest
- {
- string q { get; set; }
+ string q { get; set; }
- int MaxItems { get; set; }
- }
+ int MaxItems { get; set; }
+}
- public class SearchRequest : ISearchRequest
- {
- public string q { get; set; } = string.Empty;
+public class SearchRequest : ISearchRequest
+{
+ public string q { get; set; } = string.Empty;
- public int MaxItems { get; set; } = 10;
- }
+ public int MaxItems { get; set; } = 10;
}
diff --git a/src/Genocs.Core/Collections/Extensions/CollectionExtensions.cs b/src/Genocs.Core/Collections/Extensions/CollectionExtensions.cs
index edadc987..3722f391 100644
--- a/src/Genocs.Core/Collections/Extensions/CollectionExtensions.cs
+++ b/src/Genocs.Core/Collections/Extensions/CollectionExtensions.cs
@@ -1,7 +1,5 @@
namespace Genocs.Core.Collections.Extensions
{
- using System;
- using System.Collections.Generic;
///
/// Extension methods for Collections.
@@ -19,9 +17,9 @@ public static bool IsNullOrEmpty(this ICollection source)
///
/// Adds an item to the collection if it's not already in the collection.
///
- /// Collection
- /// Item to check and add
- /// Type of the items in the collection
+ /// Collection.
+ /// Item to check and add.
+ /// Type of the items in the collection.
/// Returns True if added, returns False if not.
public static bool AddIfNotContains(this ICollection source, T item)
{
diff --git a/src/Genocs.Core/Collections/Extensions/DictionaryExtensions.cs b/src/Genocs.Core/Collections/Extensions/DictionaryExtensions.cs
index e69a577f..925839ed 100644
--- a/src/Genocs.Core/Collections/Extensions/DictionaryExtensions.cs
+++ b/src/Genocs.Core/Collections/Extensions/DictionaryExtensions.cs
@@ -1,80 +1,76 @@
-namespace Genocs.Core.Collections.Extensions
-{
- using System;
- using System.Collections.Generic;
+namespace Genocs.Core.Collections.Extensions;
+///
+/// Extension methods for Dictionary.
+///
+public static class DictionaryExtensions
+{
///
- /// Extension methods for Dictionary.
+ /// This method is used to try to get a value in a dictionary if it does exists.
///
- public static class DictionaryExtensions
+ /// Type of the value.
+ /// The collection object.
+ /// Key.
+ /// Value of the key (or default value if key not exists).
+ /// True if key does exists in the dictionary.
+ internal static bool TryGetValue(this IDictionary dictionary, string key, out T? value)
{
- ///
- /// This method is used to try to get a value in a dictionary if it does exists.
- ///
- /// Type of the value
- /// The collection object
- /// Key
- /// Value of the key (or default value if key not exists)
- /// True if key does exists in the dictionary
- internal static bool TryGetValue(this IDictionary dictionary, string key, out T value)
+ object? valueObj;
+ if (dictionary.TryGetValue(key, out valueObj) && valueObj is T)
{
- object valueObj;
- if (dictionary.TryGetValue(key, out valueObj) && valueObj is T)
- {
- value = (T)valueObj;
- return true;
- }
-
- value = default(T);
- return false;
+ value = (T)valueObj;
+ return true;
}
- ///
- /// Gets a value from the dictionary with given key. Returns default value if can not find.
- ///
- /// Dictionary to check and get
- /// Key to find the value
- /// Type of the key
- /// Type of the value
- /// Value if found, default if can not found.
- public static TValue GetOrDefault(this IDictionary dictionary, TKey key)
- {
- TValue obj;
- return dictionary.TryGetValue(key, out obj) ? obj : default(TValue);
- }
+ value = default(T);
+ return false;
+ }
- ///
- /// Gets a value from the dictionary with given key. Returns default value if can not find.
- ///
- /// Dictionary to check and get
- /// Key to find the value
- /// A factory method used to create the value if not found in the dictionary
- /// Type of the key
- /// Type of the value
- /// Value if found, default if can not found.
- public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func factory)
- {
- TValue obj;
- if (dictionary.TryGetValue(key, out obj))
- {
- return obj;
- }
+ ///
+ /// Gets a value from the dictionary with given key. Returns default value if can not find.
+ ///
+ /// Dictionary to check and get.
+ /// Key to find the value.
+ /// Type of the key.
+ /// Type of the value.
+ /// Value if found, default if can not found.
+ public static TValue? GetOrDefault(this IDictionary dictionary, TKey key)
+ {
+ TValue? obj;
+ return dictionary.TryGetValue(key, out obj) ? obj : default(TValue);
+ }
- return dictionary[key] = factory(key);
- }
-
- ///
- /// Gets a value from the dictionary with given key. Returns default value if can not find.
- ///
- /// Dictionary to check and get
- /// Key to find the value
- /// A factory method used to create the value if not found in the dictionary
- /// Type of the key
- /// Type of the value
- /// Value if found, default if can not found.
- public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func factory)
+ ///
+ /// Gets a value from the dictionary with given key. Returns default value if can not find.
+ ///
+ /// Dictionary to check and get.
+ /// Key to find the value.
+ /// A factory method used to create the value if not found in the dictionary.
+ /// Type of the key.
+ /// Type of the value.
+ /// Value if found, default if can not found.
+ public static TValue? GetOrAdd(this IDictionary dictionary, TKey key, Func factory)
+ {
+ TValue? obj;
+ if (dictionary.TryGetValue(key, out obj))
{
- return dictionary.GetOrAdd(key, k => factory());
+ return obj;
}
+
+ return dictionary[key] = factory(key);
+ }
+
+ ///
+ /// Gets a value from the dictionary with given key. Returns default value if can not find.
+ ///
+ /// Dictionary to check and get.
+ /// Key to find the value.
+ /// A factory method used to create the value if not found in the dictionary.
+ /// Type of the key.
+ /// Type of the value.
+ /// Value if found, default if can not found.
+ public static TValue? GetOrAdd(this IDictionary dictionary, TKey key, Func factory)
+ {
+ return dictionary.GetOrAdd(key, k => factory());
}
}
\ No newline at end of file
diff --git a/src/Genocs.Core/Collections/Extensions/EnumerableExtensions.cs b/src/Genocs.Core/Collections/Extensions/EnumerableExtensions.cs
index cd71be8e..29f0c7e7 100644
--- a/src/Genocs.Core/Collections/Extensions/EnumerableExtensions.cs
+++ b/src/Genocs.Core/Collections/Extensions/EnumerableExtensions.cs
@@ -1,66 +1,60 @@
-namespace Genocs.Core.Collections.Extensions
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
+namespace Genocs.Core.Collections.Extensions;
- ///
- /// Extension methods for .
+///
+/// Extension methods for