DomainDrivenDesign.Core
0.2.0
See the version list below for details.
dotnet add package DomainDrivenDesign.Core --version 0.2.0
NuGet\Install-Package DomainDrivenDesign.Core -Version 0.2.0
<PackageReference Include="DomainDrivenDesign.Core" Version="0.2.0" />
paket add DomainDrivenDesign.Core --version 0.2.0
#r "nuget: DomainDrivenDesign.Core, 0.2.0"
// Install DomainDrivenDesign.Core as a Cake Addin #addin nuget:?package=DomainDrivenDesign.Core&version=0.2.0 // Install DomainDrivenDesign.Core as a Cake Tool #tool nuget:?package=DomainDrivenDesign.Core&version=0.2.0
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.
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
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Railway.NetCore (>= 0.0.1)
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.
Add Event class
Add Event Handler
Add Mediator to Raise Event