Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Genocs.CleanArchitectureTemplate.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="5.0.0">
<id>Genocs.CleanArchitectureTemplate</id>
<version>1.7.2</version>
<version>1.7.3</version>
<authors>Nocco Giovanni Emanuele</authors>
<owners>[Genocs] Nocco Giovanni Emanuele</owners>
<projectUrl>https://github.com/Genocs/clean-architecture-template</projectUrl>
Expand All @@ -16,13 +16,13 @@
</summary>
<description>
Install the package:
$ dotnet new -i Genocs.CleanArchitectureTemplate::1.7.2
$ dotnet new -i Genocs.CleanArchitectureTemplate::1.7.3

The full clean project:
$ dotnet new cleanarchitecture
</description>
<releaseNotes>
- Relesase 1.7.2:
- Relesase 1.7.3:
Added list of events

- Clean Architecture Principles Documentation
Expand Down
123 changes: 123 additions & 0 deletions src/template/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\dev\genocs\clean-architecture-template\src\template codebase based on best match to current usage at 7/9/2021
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]


#Core editorconfig formatting - indentation

#use soft tabs (spaces) for indentation
indent_style = space

#Formatting - new line options

#place catch statements on a new line
csharp_new_line_before_catch = true
#place else statements on a new line
csharp_new_line_before_else = true
#require members of anonymous types to be on separate lines
csharp_new_line_before_members_in_anonymous_types = true
#require members of object intializers to be on separate lines
csharp_new_line_before_members_in_object_initializers = true
#require braces to be on a new line for anonymous_types, methods, control_blocks, types, lambdas, and object_collection_array_initializers (also known as "Allman" style)
csharp_new_line_before_open_brace = anonymous_types, methods, control_blocks, types, lambdas, object_collection_array_initializers

#Formatting - organize using options

#do not place System.* using directives before other using directives
dotnet_sort_system_directives_first = false

#Formatting - spacing options

#require NO space between a cast and the value
csharp_space_after_cast = false
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

#leave code block on single line
csharp_preserve_single_line_blocks = true

#Style - Code block preferences

#prefer curly braces even for one line of code
csharp_prefer_braces = true:suggestion

#Style - expression bodied member options

#prefer block bodies for constructors
csharp_style_expression_bodied_constructors = false:suggestion
#prefer expression-bodied members for methods
csharp_style_expression_bodied_methods = true:suggestion

#Style - expression level options

#prefer out variables to be declared inline in the argument list of a method call when possible
csharp_style_inlined_variable_declaration = true:suggestion
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

#Style - Expression-level preferences

#prefer objects to be initialized using object initializers when possible
dotnet_style_object_initializer = true:suggestion
#prefer inferred anonymous type member names
dotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion

#Style - implicit and explicit types

#prefer var over explicit type in all cases, unless overridden by another code style rule
csharp_style_var_elsewhere = true:suggestion
#prefer explicit type over var to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = false:suggestion
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
csharp_style_var_when_type_is_apparent = false:suggestion

#Style - language keyword and framework type options

#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

#Style - Miscellaneous preferences

#prefer anonymous functions over local functions
csharp_style_pattern_local_over_anonymous_function = false:suggestion

#Style - modifier options

#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

#Style - Modifier preferences

#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,protected,internal,readonly,async,static,sealed,virtual,override:suggestion

#Style - Pattern matching

#prefer pattern matching instead of is expression with type casts
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion

#Style - qualification options

#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = false:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion
21 changes: 19 additions & 2 deletions src/template/Genocs.MicroserviceLight.Template.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6335BAF6-440D-4B7D-8618-DB1B32F4E1DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.MicroserviceLight.Template.Domain", "src\Genocs.MicroserviceLight.Template.Domain\Genocs.MicroserviceLight.Template.Domain.csproj", "{4D2A9497-9C04-40A4-B378-309537FA2220}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.MicroserviceLight.Template.Infrastructure", "src\Genocs.MicroserviceLight.Template.Infrastructure\Genocs.MicroserviceLight.Template.Infrastructure.csproj", "{74220BF7-8837-4B8F-B960-9CBDA65B8E68}"
Expand All @@ -23,8 +21,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.MicroserviceLight.Te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.MicroserviceLight.Template.Shared", "src\Genocs.MicroserviceLight.Template.Shared\Genocs.MicroserviceLight.Template.Shared.csproj", "{DECBE6BD-D669-40C6-8A29-8DEC5EB61ECA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.MicroserviceLight.Template.BusWorker.MassTransit", "src\Genocs.MicroserviceLight.Template.BusWorker.MassTransit\Genocs.MicroserviceLight.Template.BusWorker.MassTransit.csproj", "{B326E1D2-0FC8-45F5-B653-BD26FBDACCE3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6335BAF6-440D-4B7D-8618-DB1B32F4E1DB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1250CDBC-9DDA-447F-97E6-FCBF98F82BAC}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{5621C363-DEBC-496E-ABD2-10892BD7D649}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.MicroserviceLight.Template.Shared.Particular", "src\Genocs.MicroserviceLight.Template.Shared.Particular\Genocs.MicroserviceLight.Template.Shared.Particular.csproj", "{6CA0C8A1-36C1-47DB-83BD-CF8DE7AC8358}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -67,10 +76,18 @@ Global
{DECBE6BD-D669-40C6-8A29-8DEC5EB61ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DECBE6BD-D669-40C6-8A29-8DEC5EB61ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DECBE6BD-D669-40C6-8A29-8DEC5EB61ECA}.Release|Any CPU.Build.0 = Release|Any CPU
{B326E1D2-0FC8-45F5-B653-BD26FBDACCE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B326E1D2-0FC8-45F5-B653-BD26FBDACCE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B326E1D2-0FC8-45F5-B653-BD26FBDACCE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B326E1D2-0FC8-45F5-B653-BD26FBDACCE3}.Release|Any CPU.Build.0 = Release|Any CPU
{5621C363-DEBC-496E-ABD2-10892BD7D649}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5621C363-DEBC-496E-ABD2-10892BD7D649}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5621C363-DEBC-496E-ABD2-10892BD7D649}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5621C363-DEBC-496E-ABD2-10892BD7D649}.Release|Any CPU.Build.0 = Release|Any CPU
{6CA0C8A1-36C1-47DB-83BD-CF8DE7AC8358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CA0C8A1-36C1-47DB-83BD-CF8DE7AC8358}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CA0C8A1-36C1-47DB-83BD-CF8DE7AC8358}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CA0C8A1-36C1-47DB-83BD-CF8DE7AC8358}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 8 additions & 0 deletions src/template/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="myGet" value="https://www.myget.org/F/genocs-microservices/api/v3/index.json" protocolVersion="3" />
</packageSources>
<packageSourceCredentials>
</packageSourceCredentials>
</configuration>
52 changes: 45 additions & 7 deletions src/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sample implementation of the **Clean Architecture Principles with .NET Core**. U
## Usage

```sh
dotnet new -i Genocs.CleanArchitecture::1.7.0
dotnet new -i Genocs.CleanArchitecture::1.7.2
dotnet new cleanarchitecture -n "MyCompany.MyProject"
```

Expand Down Expand Up @@ -58,9 +58,43 @@ This example contains the implementation related to three different storage type
- Microsoft SQL Server (The popular Relational database developed by Microsoft)
- MongoDB (The popular Document DB)


### MongoDB Replicaset

To set Mongodb as a replicaset

1. Run Docker compose with 3 mongo container
2. Connect to Mongo Shell
```sh
docker exec -it mongo_db2 /bin/bash
mongo
```

3. Initialize the replicaset and check the status

```ts
rs.initiate(
{
_id : 'rs0',
members: [
{ _id : 0, host : "mongo_db1:27017" },
{ _id : 1, host : "mongo_db2:27017" },
{ _id : 2, host : "mongo_db3:27017" }
]
}
)

rs.slaveOk().ok
rs.status()
```

## Enterprise service bus

This example implement the interprise service bus using three different library
### RabbitMQ cluster

The folder docker-infrastructure contains the docker-compose file and everything required to run a two node RabbitMQ cluster.

This example implement the enterprise service bus through three different library.

- NService Bus
- Rebus
Expand All @@ -69,7 +103,7 @@ This example implement the interprise service bus using three different library

## Containers and orchestrators

The example is ready to create the docker images for both Web.Api and BusWorker
The example is ready to create the docker images for both WebApi and BusWorker


## Contributing
Expand Down Expand Up @@ -241,7 +275,7 @@ Controllers receive Requests, build the Input message then call the Use Case, yo
```c#
public sealed class CustomersController : Controller
{
// code omitted to simplify
// Code omitted to simplify...

public async Task<IActionResult> Post([FromBody][Required] RegisterRequest request)
{
Expand Down Expand Up @@ -325,7 +359,7 @@ public sealed class RegisterPresenter : IOutputPort

public void Standard(RegisterOutput output)
{
/// long object creation omitted
/// Long object creation omitted...

ViewModel = new CreatedAtRouteResult("GetCustomer",
new
Expand Down Expand Up @@ -672,7 +706,7 @@ public sealed class CustomerRepository : ICustomerRepository
```c#
public sealed class Withdraw : IUseCase
{
// properties and constructor omitted
// Properties and constructor omitted

public async Task Execute(WithdrawInput input)
{
Expand Down Expand Up @@ -906,7 +940,7 @@ namespace Genocs.WebApi.Extensions

app.UseSwaggerUI(options =>
{
// build a swagger endpoint for each discovered API version
// Build a swagger endpoint for each discovered API version
foreach (var description in provider.ApiVersionDescriptions)
{
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
Expand Down Expand Up @@ -944,7 +978,9 @@ public sealed class Startup
services.AddVersionedSwagger();

services.AddUseCases();

services.AddInMemoryPersistence();

services.AddPresentersV1();
services.AddPresentersV2();
}
Expand All @@ -961,7 +997,9 @@ public sealed class Startup
services.AddVersionedSwagger();

services.AddUseCases();

services.AddSQLServerPersistence(Configuration);

services.AddPresentersV1();
services.AddPresentersV2();
}
Expand Down
19 changes: 19 additions & 0 deletions src/template/api-workbench.rest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@url = https://localhost:5001
@apiVersion = api-version=1.0

@customerId = 8c62fa8e-7a32-4851-b2ac-21e9d62a9f2d

### Create a customer
POST {{url}}/api/v1/Customers?{{apiVersion}} HTTP/1.1
Content-Type: application/json

{
"ssn": "2410196812",
"name": "Giovanni",
"initialAmount": 100
}

### Get an existing customer
GET {{url}}/api/v1/Customers/{{customerId}}?{{apiVersion}} HTTP/1.1


Loading