-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
122 lines (107 loc) · 4.31 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>dddlib</title>
<script type="text/javascript" src="sunlight-1.22.0/sunlight-min.js"></script>
<script type="text/javascript" src="sunlight-1.22.0/lang/sunlight.csharp-min.js"></script>
<link rel="stylesheet" type="text/css" href="sunlight-1.22.0/themes/sunlight.default.css" />
<link rel="stylesheet" type="text/css" href="css/sunlight.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel='stylesheet' media='only screen and (max-width: 1399px)' href='css/index0700.css' />
<link rel='stylesheet' media='only screen and (min-width: 1400px) and (max-width: 2099px)' href='css/index1400.css' />
<link rel='stylesheet' media='only screen and (min-width: 2100px)' href='css/index2100.css' />
</head>
<body>
<header>
<h1>
<div class="crop">
<a href="http://dddlib.net">
<img src="https://raw.githubusercontent.com/dddlib/dddlib/dev/assets/dddlib_large.png" alt="dddlib" />
</a>
</div>
</h1>
<p class="title">A collection of domain driven design libraries for .NET designed to lower the barrier to entry for coding domain models</p>
</header>
<div id="container">
<div style="float: left; width: 700px;">
<h2>Model</h2>
<p>To install dddlib, run the following command in the <a href="https://docs.nuget.org/docs/start-here/using-the-package-manager-console">Package Manager Console</a>:</p>
<code>Install-Package dddlib</code>
<p>Create a domain model, for example:</p>
<pre id="model" class="sunlight-highlight-csharp">
public class Car : dddlib.AggregateRoot
{
// used for reconstitution only
protected internal Car()
{
}
public Car(string registration)
{
// business logic goes here...
this.Apply(
new CarRegistered
{
Registration = registration
});
}
[dddlib.NaturalKey]
public string Registration { get; private set; }
private void Handle(CarRegistered @event)
{
this.Registration = @event.Registration;
}
}
public class CarRegistered
{
public string Registration { get; set; }
}
</pre>
</div>
<div style="float: left; width: 700px;">
<h2>Persistence</h2>
<p>To install dddlib.Persistence, run the following command in the <a href="https://docs.nuget.org/docs/start-here/using-the-package-manager-console">Package Manager Console</a>:</p>
<code>Install-Package dddlib.Persistence</code>
<p>Persist the domain model, for example:</p>
<pre id="persistence" class="sunlight-highlight-csharp">
// replace with a valid SQL Server connection string
var connectionString = @"Server=someServer;Database=someDatabase;";
var repository =
new dddlib.Persistence.SqlServer.SqlServerEventStoreRepository(
connectionString);
var car = new Car("W807ASB");
repository.Save(car);
var sameCar = repository.Load<Car>(car.Registration);
</pre>
</div>
<div style="float: left; width: 700px;">
<h2>Event Dispatcher</h2>
<p>To install dddlib.Persistence.EventDispatcher, run the following command in the <a href="https://docs.nuget.org/docs/start-here/using-the-package-manager-console">Package Manager Console</a>:</p>
<code>Install-Package dddlib.Persistence.EventDispatcher</code>
<p>Dispatch the persisted events, for example:</p>
<pre id="eventDispatcher" class="sunlight-highlight-csharp">
// replace with a valid SQL Server connection string
var connectionString = @"Server=someServer;Database=someDatabase;";
using (new dddlib.Persistence.EventDispatcher.SqlServer.SqlServerEventDispatcher(
connectionString,
(sequenceNumber, @event) =>
{
// action to perform upon dispatch...
Console.WriteLine(
"{0}: Processed {1}",
sequenceNumber,
@event.GetType());
}))
{
// some blocking action
Console.ReadLine();
}
</pre>
</div>
<br style="clear: left;">
</div>
</body>
<script type="text/javascript">
Sunlight.highlightAll();
</script>
</html>