Skip to content

Commit 532b578

Browse files
author
Iain Scott
committed
Merge pull request #1 in TECHBUS/winton.domainmodelling.abstractions from feature/BT-6511 to master
* commit 'a174b386c15e650aca48d6c00f67b255f59ac796': Documented Entity. Fixed path in Jenkinsfile. Copied Entity type from projects currently using it.
2 parents 65f9d3e + a174b38 commit 532b578

File tree

9 files changed

+572
-0
lines changed

9 files changed

+572
-0
lines changed

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
*.swp
2+
*~
3+
4+
.vs/
5+
6+
.idea/
7+
8+
## Ignore Visual Studio temporary files, build results, and
9+
## files generated by popular Visual Studio add-ons.
10+
11+
# User-specific files
12+
*.suo
13+
*.user
14+
*.sln.docstates
15+
16+
# Build results
17+
[Dd]ebug/
18+
[Dd]ebugPublic/
19+
[Rr]elease/
20+
x64/
21+
build/
22+
bld/
23+
[Bb]in/
24+
[Oo]bj/
25+
26+
# MSTest test Results
27+
[Tt]est[Rr]esult*/
28+
[Bb]uild[Ll]og.*
29+
30+
#NUNIT
31+
*.VisualState.xml
32+
TestResult.xml
33+
34+
# Visual C++ cache files
35+
ipch/
36+
*.aps
37+
*.ncb
38+
*.opensdf
39+
*.sdf
40+
*.cachefile
41+
42+
# Visual Studio profiler
43+
*.psess
44+
*.vsp
45+
*.vspx
46+
47+
# ReSharper is a .NET coding add-in
48+
_ReSharper*/
49+
*.[Rr]e[Ss]harper
50+
*.DotSettings.user
51+
52+
# TeamCity is a build add-in
53+
_TeamCity*
54+
55+
# DotCover is a Code Coverage Tool
56+
*.dotCover
57+
58+
# Click-Once directory
59+
publish/
60+
61+
# Publish Web Output
62+
*.[Pp]ublish.xml
63+
*.azurePubxml
64+
*.pubxml
65+
66+
# NuGet Packages Directory
67+
packages/*
68+
## TODO: If the tool you use requires repositories.config
69+
## uncomment the next line
70+
#!packages/repositories.config
71+
72+
# Enable "build/" folder in the NuGet Packages folder since
73+
# NuGet packages use it for MSBuild targets.
74+
# This line needs to be after the ignore of the build folder
75+
# (and the packages folder if the line above has been uncommented)
76+
!packages/build/
77+
78+
# Others
79+
*.Cache
80+
ClientBin/
81+
~$*
82+
*~
83+
*.dbmdl
84+
*.dbproj.schemaview
85+
*.pfx
86+
*.publishsettings
87+
node_modules/
88+
89+
# Backup & report files from converting an old project file
90+
# to a newer Visual Studio version. Backup files are not needed,
91+
# because we have git ;-)
92+
_UpgradeReport_Files/
93+
Backup*/
94+
UpgradeLog*.XML
95+
UpgradeLog*.htm
96+
97+
# SQL Server files
98+
*.mdf
99+
*.ldf
100+
101+
## Certificates
102+
*.pem
103+
104+
logs/
105+
*.log
106+
*.sln.DotSettings

GitVersionConfig.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
assembly-versioning-scheme: MajorMinorPatch
2+
mode: ContinuousDeployment
3+
4+
# It would be better to use smarter regexes instead of duplicating everything for local and remote cases.
5+
# However, GitVersion has some built-in patterns which cannot be removed and these would cause clashes.
6+
branches:
7+
8+
# These branch patterns cover all local cases
9+
master:
10+
regex: master
11+
tag: master
12+
increment: Minor
13+
prevent-increment-of-merged-branch-version: true
14+
feature:
15+
regex: feature[/-]
16+
tag: a{BranchName}
17+
increment: Minor
18+
prevent-increment-of-merged-branch-version: false
19+
patch:
20+
regex: patch[/-]
21+
tag: useBranchName
22+
increment: Patch
23+
prevent-increment-of-merged-branch-version: false
24+
release:
25+
regex: release[/-]
26+
tag: rc
27+
increment: None
28+
prevent-increment-of-merged-branch-version: false
29+
30+
# These branch patterns cover all remote cases
31+
origin/master:
32+
regex: origin/master
33+
tag: master
34+
increment: Minor
35+
prevent-increment-of-merged-branch-version: true
36+
origin/feature:
37+
regex: origin/feature[/-]
38+
tag: a{BranchName}
39+
increment: Minor
40+
prevent-increment-of-merged-branch-version: false
41+
origin/patch:
42+
regex: origin/patch[/-]
43+
tag: useBranchName
44+
increment: Patch
45+
prevent-increment-of-merged-branch-version: false
46+
origin/release:
47+
regex: origin/release[/-]
48+
tag: rc
49+
increment: None
50+
prevent-increment-of-merged-branch-version: false

Jenkinsfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!groovy
2+
3+
node {
4+
step([$class: 'StashNotifier'])
5+
try {
6+
stage("Clone") {
7+
checkout scm
8+
}
9+
10+
stage("Restore") {
11+
bat "dotnet restore --source https://packages/repository/nuget-group-libs/"
12+
}
13+
14+
stage("Build") {
15+
bat("\"${tool 'MSBuild15'}\" /p:Configuration=Release")
16+
}
17+
18+
stage("Test") {
19+
dir("test\\Winton.DomainModelling.Abstractions.Tests") {
20+
bat("dotnet test Winton.DomainModelling.Abstractions.Tests.csproj --configuration Release --no-restore --no-build")
21+
}
22+
}
23+
24+
stage("Publish") {
25+
dir("src\\Winton.DomainModelling.Abstractions\\bin") {
26+
bat("dotnet nuget push **\\*.nupkg --source https://packages/repository/nuget-hosted-libs/")
27+
}
28+
}
29+
30+
stage("Archive") {
31+
archive "**\\*.nupkg"
32+
}
33+
34+
currentBuild.result = "SUCCESS"
35+
}
36+
catch (err) {
37+
currentBuild.result = "FAILURE"
38+
throw err
39+
}
40+
finally{
41+
step([$class: 'StashNotifier'])
42+
}
43+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27703.2026
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{697902B3-26B1-490D-BC64-39298D6DAFC4}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{02075BDC-A66D-4346-8093-2F2667660F36}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winton.DomainModelling.Abstractions", "src\Winton.DomainModelling.Abstractions\Winton.DomainModelling.Abstractions.csproj", "{4CC49F58-367B-4E87-8925-49D913FA7BD1}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winton.DomainModelling.Abstractions.Tests", "test\Winton.DomainModelling.Abstractions.Tests\Winton.DomainModelling.Abstractions.Tests.csproj", "{8FD5A9B0-44ED-470F-A0F0-721E55B5790D}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Release|Any CPU = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{4CC49F58-367B-4E87-8925-49D913FA7BD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{4CC49F58-367B-4E87-8925-49D913FA7BD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{4CC49F58-367B-4E87-8925-49D913FA7BD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{4CC49F58-367B-4E87-8925-49D913FA7BD1}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{8FD5A9B0-44ED-470F-A0F0-721E55B5790D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{8FD5A9B0-44ED-470F-A0F0-721E55B5790D}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{8FD5A9B0-44ED-470F-A0F0-721E55B5790D}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{8FD5A9B0-44ED-470F-A0F0-721E55B5790D}.Release|Any CPU.Build.0 = Release|Any CPU
28+
EndGlobalSection
29+
GlobalSection(SolutionProperties) = preSolution
30+
HideSolutionNode = FALSE
31+
EndGlobalSection
32+
GlobalSection(NestedProjects) = preSolution
33+
{4CC49F58-367B-4E87-8925-49D913FA7BD1} = {697902B3-26B1-490D-BC64-39298D6DAFC4}
34+
{8FD5A9B0-44ED-470F-A0F0-721E55B5790D} = {02075BDC-A66D-4346-8093-2F2667660F36}
35+
EndGlobalSection
36+
GlobalSection(ExtensibilityGlobals) = postSolution
37+
SolutionGuid = {6AC36F05-9D1F-4E69-A8F5-3A36B8065019}
38+
EndGlobalSection
39+
EndGlobal
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using System;
2+
3+
namespace Winton.DomainModelling
4+
{
5+
/// <inheritdoc />
6+
/// <summary>
7+
/// A base class to implement entity types, which are defined by their identity rather than their attributes.
8+
/// </summary>
9+
/// <typeparam name="TEntityId">The ID type for the entity type.</typeparam>
10+
public abstract class Entity<TEntityId> : IEquatable<Entity<TEntityId>>
11+
where TEntityId : IEquatable<TEntityId>
12+
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="Entity{TEntityId}" /> class.
15+
/// </summary>
16+
/// <param name="id">The ID for the entity.</param>
17+
protected Entity(TEntityId id)
18+
{
19+
Id = id;
20+
}
21+
22+
/// <summary>
23+
/// Gets the ID for the entity.
24+
/// </summary>
25+
public TEntityId Id { get; }
26+
27+
/// <summary>
28+
/// Indicates whether two entities are equal.
29+
/// </summary>
30+
/// <param name="left">The first entity.</param>
31+
/// <param name="right">The second entity.</param>
32+
/// <returns><see langword="true" /> if the entities have the same ID; otherwise, <see langword="false" />.</returns>
33+
public static bool operator ==(Entity<TEntityId> left, Entity<TEntityId> right)
34+
{
35+
return Equals(left, right);
36+
}
37+
38+
/// <summary>
39+
/// Indicates whether two entities are unequal.
40+
/// </summary>
41+
/// <param name="left">The first entity.</param>
42+
/// <param name="right">The second entity.</param>
43+
/// <returns><see langword="true" /> if the entities have different IDs; otherwise, <see langword="false" />.</returns>
44+
public static bool operator !=(Entity<TEntityId> left, Entity<TEntityId> right)
45+
{
46+
return !Equals(left, right);
47+
}
48+
49+
/// <inheritdoc />
50+
/// <summary>
51+
/// Indicates whether the current entity is equal to another entity.
52+
/// </summary>
53+
/// <param name="other">An entity to compare with this entity.</param>
54+
/// <returns>
55+
/// <see langword="true" /> if the current entity has the same ID as the <paramref name="other" /> entity;
56+
/// otherwise, <see langword="false" />.
57+
/// </returns>
58+
public bool Equals(Entity<TEntityId> other)
59+
{
60+
if (other is null)
61+
{
62+
return false;
63+
}
64+
65+
if (ReferenceEquals(this, other))
66+
{
67+
return true;
68+
}
69+
70+
if (GetType() != other.GetType())
71+
{
72+
return false;
73+
}
74+
75+
return !Id.Equals(default(TEntityId)) && !other.Id.Equals(default(TEntityId)) && Id.Equals(other.Id);
76+
}
77+
78+
/// <summary>
79+
/// Determines whether the specified object is equal to the current object.
80+
/// </summary>
81+
/// <param name="obj">The object to compare with the current object.</param>
82+
/// <returns>
83+
/// <see langword="true" /> if the specified object is equal to the current object; otherwise,
84+
/// <see langword="false" />.
85+
/// </returns>
86+
public override bool Equals(object obj)
87+
{
88+
return Equals(obj as Entity<TEntityId>);
89+
}
90+
91+
/// <summary>
92+
/// Serves as the default hash function.
93+
/// </summary>
94+
/// <returns>A hash code for the current object.</returns>
95+
public override int GetHashCode()
96+
{
97+
return Id.GetHashCode();
98+
}
99+
}
100+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Authors>Winton</Authors>
5+
<Company>Winton</Company>
6+
<Copyright>Copyright 2018 Winton</Copyright>
7+
<Description>Provides common abstractions for domain modelling.</Description>
8+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
9+
<NoWarn>$(NoWarn);SA0001;SA1101;SA1309;SA1413;SA1633;SA1652</NoWarn>
10+
<PackageId>Winton.DomainModelling.Abstractions</PackageId>
11+
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
12+
<PackageTags>Winton, Domain, Driven, Design, Modelling, Abstractions, DDD</PackageTags>
13+
<PackageVersion>$(NuGetVersion)</PackageVersion>
14+
<RootNamespace>Winton.DomainModelling</RootNamespace>
15+
<TargetFramework>netstandard1.0</TargetFramework>
16+
<Title>Winton Domain Modelling Abstractions</Title>
17+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
18+
</PropertyGroup>
19+
20+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
21+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<AdditionalFiles Include="..\..\stylecop.json" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<PackageReference Include="Bt.Tooling.ReSharper" Version="1.3.0" PrivateAssets="All" />
30+
<PackageReference Include="GitVersionTask" Version="4.0.0-beta0012" PrivateAssets="All" />
31+
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="All" />
32+
</ItemGroup>
33+
34+
</Project>

0 commit comments

Comments
 (0)