Skip to content

Commit 8c50b90

Browse files
committed
first commit
0 parents  commit 8c50b90

29 files changed

+2363
-0
lines changed

.gitignore

Whitespace-only changes.

LICENSE

Lines changed: 675 additions & 0 deletions
Large diffs are not rendered by default.

readme.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# RequestR - Getting Started
2+
3+
## 1) Create the Request and Request Handler classes
4+
5+
The request can be any C# class.
6+
7+
```csharp
8+
internal class PresentProductsRequest
9+
{
10+
}
11+
```
12+
13+
The request handler must implement the `IRequestHandler` interface.
14+
15+
```csharp
16+
internal class PresentProductsRequestHandler : IRequestHandler<PresentProductsRequest, List<Product>>
17+
{
18+
public List<Product> Handle(PresentProductsRequest request)
19+
{
20+
// Return the list of products.
21+
}
22+
}
23+
```
24+
25+
## 2) Create the Request Bus and register the Request Handler
26+
27+
```csharp
28+
RequestBus requestBus = new RequestBus();
29+
requestBus.RegisterHandler<PresentProductsRequestHandler>();
30+
```
31+
32+
## 3) Send a new Request
33+
34+
```csharp
35+
PresentProductsRequest request = new PresentProductsRequest();
36+
List<Product> products = requestBus.Send<PresentProductsRequest, List<Product>>(request);
37+
```

sources/.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

sources/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.vs/
2+
bin/
3+
obj/
4+
*.suo
5+
*.user
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RequestR
2+
// Copyright (C) 2021 Dust in the Wind
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
namespace DustInTheWind.RequestR.Demo
18+
{
19+
internal class PresentProductsRequest
20+
{
21+
}
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RequestR
2+
// Copyright (C) 2021 Dust in the Wind
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
using System.Collections.Generic;
18+
19+
namespace DustInTheWind.RequestR.Demo
20+
{
21+
internal class PresentProductsRequestHandler : IRequestHandler<PresentProductsRequest, List<Product>>
22+
{
23+
public List<Product> Handle(PresentProductsRequest request)
24+
{
25+
return new List<Product>();
26+
}
27+
}
28+
}

sources/RequestR.Demo/Product.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RequestR
2+
// Copyright (C) 2021 Dust in the Wind
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
namespace DustInTheWind.RequestR.Demo
18+
{
19+
internal class Product
20+
{
21+
public string Name { get; set; }
22+
23+
public uint Quantity { get; set; }
24+
25+
public decimal Price { get; set; }
26+
}
27+
}

sources/RequestR.Demo/Program.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RequestR
2+
// Copyright (C) 2021 Dust in the Wind
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
using System;
18+
using System.Collections.Generic;
19+
20+
namespace DustInTheWind.RequestR.Demo
21+
{
22+
internal class Program
23+
{
24+
private static void Main(string[] args)
25+
{
26+
// Setup request bus
27+
RequestBus requestBus = new RequestBus();
28+
requestBus.RegisterHandler<PresentProductsRequestHandler>();
29+
30+
// Send request
31+
PresentProductsRequest request = new PresentProductsRequest();
32+
List<Product> products = requestBus.Send<PresentProductsRequest, List<Product>>(request);
33+
34+
// Display response
35+
foreach (Product product in products)
36+
{
37+
Console.WriteLine();
38+
Console.WriteLine("Product: " + product.Name);
39+
Console.WriteLine("Price: " + product.Price);
40+
Console.WriteLine("Quantity: " + product.Quantity);
41+
}
42+
}
43+
}
44+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net5.0</TargetFramework>
6+
<AssemblyName>DustInTheWind.RequestR.Demo</AssemblyName>
7+
<RootNamespace>DustInTheWind.RequestR.Demo</RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\RequestR\RequestR.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)