From 74e959dcb6f44041a2d8e1241b5c10c6f0fb4514 Mon Sep 17 00:00:00 2001 From: Vaughn Vernon Date: Sun, 28 Apr 2013 04:18:35 -0600 Subject: [PATCH] moh-abed added Collaboration Collaborators and Tenant. --- .gitignore | 1 + .../Author.cs | 15 ++++ .../Collaborator .cs | 73 +++++++++++++++++++ .../Creator.cs | 15 ++++ .../ICollaboratorService.cs | 17 +++++ .../Moderator.cs | 15 ++++ .../Owner.cs | 15 ++++ .../Participant.cs | 15 ++++ .../Tenant.cs | 12 +++ iddd_collaboration/iddd_collaboration.csproj | 13 +++- 10 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Author.cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Collaborator .cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Creator.cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/ICollaboratorService.cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Moderator.cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Owner.cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Participant.cs create mode 100644 iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Tenants/Tenant.cs diff --git a/.gitignore b/.gitignore index 5f1d509..c9f3aeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +IDDD_Samples.suo /iddd_agilepm/bin/ /iddd_agilepm/obj/ /iddd_collaboration/bin/ diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Author.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Author.cs new file mode 100644 index 0000000..e58dae8 --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Author.cs @@ -0,0 +1,15 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + public sealed class Author : Collaborator + { + public Author(string identity, string name, string emailAddress) + : base(identity, name, emailAddress) + { + } + + protected override int GetHashPrimeValue() + { + return 19; + } + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Collaborator .cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Collaborator .cs new file mode 100644 index 0000000..268a83b --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Collaborator .cs @@ -0,0 +1,73 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + using System; + + public abstract class Collaborator : IComparable + { + protected Collaborator() + { + } + + protected Collaborator(string identity, string name, string emailAddress) + { + Identity = identity; + Name = name; + EmailAddress = emailAddress; + } + + public string EmailAddress { get; private set; } + public string Identity { get; private set; } + public string Name { get; private set; } + + public int CompareTo(Collaborator collaborator) + { + var diff = String.Compare(Identity, collaborator.Identity, StringComparison.Ordinal); + + if (diff == 0) + { + diff = String.Compare(EmailAddress, collaborator.EmailAddress, StringComparison.Ordinal); + + if (diff == 0) + { + diff = String.Compare(Name, collaborator.Name, StringComparison.Ordinal); + } + } + + return diff; + } + + public override bool Equals(object anObject) + { + var equalObjects = false; + + if (anObject != null && GetType() == anObject.GetType()) + { + var typedObject = (Collaborator)anObject; + equalObjects = + EmailAddress.Equals(typedObject.EmailAddress) && + Identity.Equals(typedObject.Identity) && + Name.Equals(typedObject.Name); + } + + return equalObjects; + } + + public override int GetHashCode() + { + var hash = 57691 * GetHashPrimeValue() + + Identity.GetHashCode() + + Name.GetHashCode() + + EmailAddress.GetHashCode(); + + return hash; + } + + public override string ToString() + { + return GetType().Name + + " [emailAddress=" + EmailAddress + ", identity=" + Identity + ", Name=" + Name + "]"; + } + + protected abstract int GetHashPrimeValue(); + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Creator.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Creator.cs new file mode 100644 index 0000000..a37f3a3 --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Creator.cs @@ -0,0 +1,15 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + public sealed class Creator : Collaborator + { + public Creator(string identity, string name, string emailAddress) + : base(identity, name, emailAddress) + { + } + + protected override int GetHashPrimeValue() + { + return 43; + } + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/ICollaboratorService.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/ICollaboratorService.cs new file mode 100644 index 0000000..740b3af --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/ICollaboratorService.cs @@ -0,0 +1,17 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + using SaaSOvation.Collaboration.Domain.Model.Tenants; + + public interface ICollaboratorService + { + Author AuthorFrom(Tenant tenant, string identity); + + Creator CreatorFrom(Tenant tenant, string identity); + + Moderator ModeratorFrom(Tenant tenant, string identity); + + Owner OwnerFrom(Tenant enant, string identity); + + Participant ParticipantFrom(Tenant tenant, string identity); + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Moderator.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Moderator.cs new file mode 100644 index 0000000..b665bd3 --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Moderator.cs @@ -0,0 +1,15 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + public sealed class Moderator : Collaborator + { + public Moderator(string identity, string name, string emailAddress) + : base(identity, name, emailAddress) + { + } + + protected override int GetHashPrimeValue() + { + return 59; + } + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Owner.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Owner.cs new file mode 100644 index 0000000..68a5610 --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Owner.cs @@ -0,0 +1,15 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + public sealed class Owner : Collaborator + { + public Owner(string identity, string name, string emailAddress) + : base(identity, name, emailAddress) + { + } + + protected override int GetHashPrimeValue() + { + return 29; + } + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Participant.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Participant.cs new file mode 100644 index 0000000..467128d --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Participant.cs @@ -0,0 +1,15 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Collaborators +{ + public sealed class Participant : Collaborator + { + public Participant(string identity, string name, string emailAddress) + : base(identity, name, emailAddress) + { + } + + protected override int GetHashPrimeValue() + { + return 23; + } + } +} diff --git a/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Tenants/Tenant.cs b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Tenants/Tenant.cs new file mode 100644 index 0000000..6fcb0eb --- /dev/null +++ b/iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Tenants/Tenant.cs @@ -0,0 +1,12 @@ +namespace SaaSOvation.Collaboration.Domain.Model.Tenants +{ + public sealed class Tenant + { + public Tenant(string id) + { + this.Id = id; + } + + public string Id { get; private set; } + } +} diff --git a/iddd_collaboration/iddd_collaboration.csproj b/iddd_collaboration/iddd_collaboration.csproj index 37abad7..bdb7bc3 100644 --- a/iddd_collaboration/iddd_collaboration.csproj +++ b/iddd_collaboration/iddd_collaboration.csproj @@ -40,8 +40,19 @@ - + + + + + + + + + + + +