-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Szymon Szylhabel
committed
Jun 21, 2017
1 parent
478f4bf
commit 6930471
Showing
153 changed files
with
5,102 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*/bin/* | ||
packages/ | ||
bin/ | ||
*.suo | ||
desktop.ini | ||
*.user | ||
**/obj/* | ||
*.mdf | ||
*.ldf |
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,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{7D8D2FEB-C2E5-4D54-8369-21DE2D44984A}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CQRS.Base</RootNamespace> | ||
<AssemblyName>CQRS.Base</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="NHibernate, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Command\ICommandHandler.cs" /> | ||
<Compile Include="Command\ICommandSender.cs" /> | ||
<Compile Include="Events\IEventListener.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Query\PaginatedResult.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\PhotoStock.Sales.Domain\PhotoStock.Sales.Domain.csproj"> | ||
<Project>{2230C68D-558A-463F-B3ED-427968DECB2E}</Project> | ||
<Name>PhotoStock.Sales.Domain</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
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,7 @@ | ||
namespace CQRS.Base.Command | ||
{ | ||
public interface ICommandHandler<TCommand> | ||
{ | ||
void Handle(TCommand command); | ||
} | ||
} |
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,7 @@ | ||
namespace CQRS.Base.Command | ||
{ | ||
public interface ICommandSender | ||
{ | ||
void Send<TCommand>(TCommand command); | ||
} | ||
} |
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,7 @@ | ||
namespace CQRS.Base.Events | ||
{ | ||
public interface IEventListener<in TEvent> | ||
{ | ||
void Handle(TEvent eventData); | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("CQRS.Base")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CQRS.Base")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("7d8d2feb-c2e5-4d54-8369-21de2d44984a")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace CQRS.Base.Query | ||
{ | ||
public class PaginatedResult<T> | ||
{ | ||
public List<T> Items { get; private set; } | ||
public int PageSize { get; private set; } | ||
public int PageNumber { get; private set; } | ||
public int PagesCount { get; private set; } | ||
public int TotalItemsCount { get; private set; } | ||
|
||
public PaginatedResult(int pageNumber, int pageSize) | ||
{ | ||
PageNumber = pageNumber; | ||
PageSize = pageSize; | ||
Items = new List<T>(); | ||
PagesCount = 0; | ||
TotalItemsCount = 0; | ||
} | ||
|
||
public PaginatedResult(List<T> items, int pageNumber, int pageSize, int totalItemsCount) | ||
{ | ||
Items = items; | ||
PageNumber = pageNumber; | ||
PageSize = pageSize; | ||
PagesCount = CountPages(pageSize, totalItemsCount); | ||
TotalItemsCount = totalItemsCount; | ||
} | ||
|
||
private int CountPages(int size, int itemsCount) | ||
{ | ||
return (int)Math.Ceiling((double)itemsCount / size); | ||
} | ||
} | ||
} |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Iesi.Collections" version="4.0.0.4000" targetFramework="net452" /> | ||
<package id="NHibernate" version="4.0.4.4000" targetFramework="net452" /> | ||
</packages> |
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,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{F8D43559-8792-498B-AB51-211CA04CB4DF}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>DDD.Base</RootNamespace> | ||
<AssemblyName>DDD.Base</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Domain\AggregateRoot.cs" /> | ||
<Compile Include="Domain\AgregateId.cs" /> | ||
<Compile Include="Domain\DomainOperationException.cs" /> | ||
<Compile Include="Domain\Entity.cs" /> | ||
<Compile Include="Domain\Exceptions\IllegalStateException.cs" /> | ||
<Compile Include="Domain\IDomainEvent.cs" /> | ||
<Compile Include="Domain\IDomainEventPublisher.cs" /> | ||
<Compile Include="Domain\IDependencyInjector.cs" /> | ||
<Compile Include="Domain\IGenericRepository.cs" /> | ||
<Compile Include="Domain\ValueObject.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Sagas\ISagaManager.cs" /> | ||
<Compile Include="SharedKernel\Specification\AndSpecification.cs" /> | ||
<Compile Include="SharedKernel\Specification\CompositeSpecification.cs" /> | ||
<Compile Include="SharedKernel\Specification\ConjunctionSpecification.cs" /> | ||
<Compile Include="SharedKernel\Specification\DisjunctionSpecification.cs" /> | ||
<Compile Include="SharedKernel\Specification\ISpecification.cs" /> | ||
<Compile Include="SharedKernel\Specification\NotSpecification.cs" /> | ||
<Compile Include="SharedKernel\Specification\OrSpecification.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
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,44 @@ | ||
using System; | ||
|
||
namespace DDD.Base.Domain | ||
{ | ||
public abstract class AggregateRoot | ||
{ | ||
public enum AggregateStatus | ||
{ | ||
ACTIVE, ARCHIVE | ||
} | ||
|
||
public AggregateId AggregateId { get; private set; } | ||
|
||
public int Version { get; private set; } | ||
private AggregateStatus _aggregateStatus = AggregateStatus.ACTIVE; | ||
|
||
protected IDomainEventPublisher EventPublisher { get; private set; } | ||
|
||
protected AggregateRoot() | ||
{ | ||
Version = 0; | ||
} | ||
|
||
public AggregateRoot(AggregateId aggregateId) | ||
{ | ||
AggregateId = aggregateId; | ||
} | ||
|
||
public void MarkAsRemoved() | ||
{ | ||
_aggregateStatus = AggregateStatus.ARCHIVE; | ||
} | ||
|
||
public bool IsRemoved() | ||
{ | ||
return _aggregateStatus == AggregateStatus.ARCHIVE; | ||
} | ||
|
||
protected void DomainError(string message) | ||
{ | ||
throw new DomainOperationException(AggregateId, message); | ||
} | ||
} | ||
} |
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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace DDD.Base.Domain | ||
{ | ||
public class AggregateId : ValueObject | ||
{ | ||
private string _innerId; | ||
|
||
public AggregateId(string value) | ||
{ | ||
if (value == null) | ||
{ | ||
throw new ArgumentNullException("value"); | ||
} | ||
_innerId = value; | ||
} | ||
|
||
protected AggregateId() | ||
{ | ||
} | ||
|
||
public static AggregateId Generate() | ||
{ | ||
return new AggregateId(Guid.NewGuid().ToString()); | ||
} | ||
|
||
public static implicit operator AggregateId(string value) | ||
{ | ||
return new AggregateId(value); | ||
} | ||
|
||
public static implicit operator string(AggregateId aggregateId) | ||
{ | ||
if (aggregateId != null) | ||
{ | ||
return aggregateId._innerId; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
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,14 @@ | ||
using System; | ||
|
||
namespace DDD.Base.Domain | ||
{ | ||
public class DomainOperationException : Exception | ||
{ | ||
public AggregateId AggregateId { get; set; } | ||
|
||
public DomainOperationException(AggregateId aggregateId, string message) : base(message) | ||
{ | ||
AggregateId = aggregateId; | ||
} | ||
} | ||
} |
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,7 @@ | ||
namespace DDD.Base.Domain | ||
{ | ||
public abstract class Entity | ||
{ | ||
public int Id { get; private set; } | ||
} | ||
} |
Oops, something went wrong.