forked from VaughnVernon/IDDD_Samples_NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moh-abed added Collaboration Collaborators and Tenant.
- Loading branch information
1 parent
c08a247
commit 74e959d
Showing
10 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
IDDD_Samples.suo | ||
/iddd_agilepm/bin/ | ||
/iddd_agilepm/obj/ | ||
/iddd_collaboration/bin/ | ||
|
15 changes: 15 additions & 0 deletions
15
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Author.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Collaborator .cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
namespace SaaSOvation.Collaboration.Domain.Model.Collaborators | ||
{ | ||
using System; | ||
|
||
public abstract class Collaborator : IComparable<Collaborator> | ||
{ | ||
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(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Creator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ollaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/ICollaboratorService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Moderator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Owner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Collaborators/Participant.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
iddd_collaboration/SaaSOvation.Collaboration.Domain.Model.Tenants/Tenant.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters