DomainDrivenDesign.Core
0.2.1
This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.
Install-Package DomainDrivenDesign.Core -Version 0.2.1
dotnet add package DomainDrivenDesign.Core --version 0.2.1
<PackageReference Include="DomainDrivenDesign.Core" Version="0.2.1" />
paket add DomainDrivenDesign.Core --version 0.2.1
#r "nuget: DomainDrivenDesign.Core, 0.2.1"
// Install DomainDrivenDesign.Core as a Cake Addin
#addin nuget:?package=DomainDrivenDesign.Core&version=0.2.1
// Install DomainDrivenDesign.Core as a Cake Tool
#tool nuget:?package=DomainDrivenDesign.Core&version=0.2.1
DDDCore
This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.
Articles about this Framework
How to Build a good one Value Object.
What is Domain Services? How to use it?.
Videos (English)
DDD Course - Class 00 - Overview - NetCore C#.
Videos (Portuguese)
DDD Course - Class 00 - Overview - NetCore C#.
DDD Course - Class 01 - Modeling Best Practices.
Documentation (Wiki)
Features
DomainDrivenDesign.Core
- Entity
- Value Object
- Value Object Validations
- Event
- Raise Events (Mediator)
DomainDrivenDesign.Core.CQRS
- Commands
- Queries
- MediatirCQRS to dispatch Commands and Queries
DomainDrivenDesign.Core.EventSourcing (Under development)
Nuget Packages
Installation
You can install using nuget Package Manager
Install-Package DomainDrivenDesign.Core -Version 0.1.3
Install-Package DomainDrivenDesign.Core.CQRS -Version 0.0.1
Or using .Net Cli
dotnet add package DomainDrivenDesign.Core --version 0.1.3
dotnet add package DomainDrivenDesign.Core.CQRS --version 0.0.1
Technologies used:
- Railway.NetCore
Usage
You can use Value Object like this one:
Money
using DomainDrivenDesign.Core.Models;
using Railway.NetCore.Core;
using System;
using System.Collections.Generic;
using System.Text;
public class Money : ValueObject<Money>
{
protected Money(Decimal amount, string currencyCode)
{
this.CheckRule(new CurrencyShouldBeSpecified(currencyCode));
this.Amount = amount;
this.Currency = currency;
}
protected Money(Decimal amount, Currency currency)
{
this.CheckRule(new AmountShouldBePositive(amount));
this.Amount = amount;
this.Currency = currency;
}
public static Money FromDecimal(
decimal amount,
string currency)
=> new Money(amount, currency);
public decimal ToDecimal()
=> Amount;
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
public Decimal Amount { get; }
public String Currency { get; }
}
CurrencyShouldBeSpecified.cs
using DomainDrivenDesign.Core.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
public class CurrencyShouldBeSpecified : IValidationRule
{
private readonly string _value;
internal CurrencyShouldBeSpecified(string value)
{
this._value = value;
}
public string Message => "Currency code must be specified";
public bool IsBroken()
{
return (string.IsNullOrEmpty(_value));
}
}
Also, you can use Entity Object.
Payment.cs Entity Sample
using DomainDrivenDesign.Core.Models;
using Railway.NetCore.Core;
using System;
using System.Collections.Generic;
using System.Text;
public class Payment : Entity
{
public Card Card { get; protected set; }
public Money Amount { get; protected set; }
public string BeneficiaryAlias { get; protected set; }
public DateTime CreatedOn { get; protected set; }
public static Result<Payment> CreateNewCardPayment(Card card, Money amount, string beneficiaryAlias)
{
return Result.Success(new Payment(card, amount, beneficiaryAlias));
}
private Payment(Card card, Money amount, string beneficiaryAlias) : base()
{
this.Card = card;
this.Amount = amount;
this.BeneficiaryAlias = beneficiaryAlias;
this.CreatedOn = DateTime.Now;
}
}
Soon Mediator, Command, Query and Handlers samples.
If you wish you can see this samples on Sample Project.
License
MIT
DDDCore
This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.
Articles about this Framework
How to Build a good one Value Object.
What is Domain Services? How to use it?.
Videos (English)
DDD Course - Class 00 - Overview - NetCore C#.
Videos (Portuguese)
DDD Course - Class 00 - Overview - NetCore C#.
DDD Course - Class 01 - Modeling Best Practices.
Documentation (Wiki)
Features
DomainDrivenDesign.Core
- Entity
- Value Object
- Value Object Validations
- Event
- Raise Events (Mediator)
DomainDrivenDesign.Core.CQRS
- Commands
- Queries
- MediatirCQRS to dispatch Commands and Queries
DomainDrivenDesign.Core.EventSourcing (Under development)
Nuget Packages
Installation
You can install using nuget Package Manager
Install-Package DomainDrivenDesign.Core -Version 0.1.3
Install-Package DomainDrivenDesign.Core.CQRS -Version 0.0.1
Or using .Net Cli
dotnet add package DomainDrivenDesign.Core --version 0.1.3
dotnet add package DomainDrivenDesign.Core.CQRS --version 0.0.1
Technologies used:
- Railway.NetCore
Usage
You can use Value Object like this one:
Money
using DomainDrivenDesign.Core.Models;
using Railway.NetCore.Core;
using System;
using System.Collections.Generic;
using System.Text;
public class Money : ValueObject<Money>
{
protected Money(Decimal amount, string currencyCode)
{
this.CheckRule(new CurrencyShouldBeSpecified(currencyCode));
this.Amount = amount;
this.Currency = currency;
}
protected Money(Decimal amount, Currency currency)
{
this.CheckRule(new AmountShouldBePositive(amount));
this.Amount = amount;
this.Currency = currency;
}
public static Money FromDecimal(
decimal amount,
string currency)
=> new Money(amount, currency);
public decimal ToDecimal()
=> Amount;
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
public Decimal Amount { get; }
public String Currency { get; }
}
CurrencyShouldBeSpecified.cs
using DomainDrivenDesign.Core.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
public class CurrencyShouldBeSpecified : IValidationRule
{
private readonly string _value;
internal CurrencyShouldBeSpecified(string value)
{
this._value = value;
}
public string Message => "Currency code must be specified";
public bool IsBroken()
{
return (string.IsNullOrEmpty(_value));
}
}
Also, you can use Entity Object.
Payment.cs Entity Sample
using DomainDrivenDesign.Core.Models;
using Railway.NetCore.Core;
using System;
using System.Collections.Generic;
using System.Text;
public class Payment : Entity
{
public Card Card { get; protected set; }
public Money Amount { get; protected set; }
public string BeneficiaryAlias { get; protected set; }
public DateTime CreatedOn { get; protected set; }
public static Result<Payment> CreateNewCardPayment(Card card, Money amount, string beneficiaryAlias)
{
return Result.Success(new Payment(card, amount, beneficiaryAlias));
}
private Payment(Card card, Money amount, string beneficiaryAlias) : base()
{
this.Card = card;
this.Amount = amount;
this.BeneficiaryAlias = beneficiaryAlias;
this.CreatedOn = DateTime.Now;
}
}
Soon Mediator, Command, Query and Handlers samples.
If you wish you can see this samples on Sample Project.
License
MIT
Release Notes
Add Event class
Add Event Handler
Add Mediator to Raise Event
Dependencies
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Railway.NetCore (>= 0.0.1)
Used By
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DomainDrivenDesign.Core:
Package | Downloads |
---|---|
DomainDrivenDesign.Core.CQRS
This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.
|
GitHub repositories
This package is not used by any popular GitHub repositories.