Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Szylhabel committed Jun 21, 2017
1 parent 478f4bf commit 6930471
Show file tree
Hide file tree
Showing 153 changed files with 5,102 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*/bin/*
packages/
bin/
*.suo
desktop.ini
*.user
**/obj/*
*.mdf
*.ldf
74 changes: 74 additions & 0 deletions CQRS.Base/CQRS.Base.csproj
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>
7 changes: 7 additions & 0 deletions CQRS.Base/Command/ICommandHandler.cs
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);
}
}
7 changes: 7 additions & 0 deletions CQRS.Base/Command/ICommandSender.cs
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);
}
}
7 changes: 7 additions & 0 deletions CQRS.Base/Events/IEventListener.cs
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);
}
}
36 changes: 36 additions & 0 deletions CQRS.Base/Properties/AssemblyInfo.cs
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")]
37 changes: 37 additions & 0 deletions CQRS.Base/Query/PaginatedResult.cs
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);
}
}
}
5 changes: 5 additions & 0 deletions CQRS.Base/packages.config
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>
71 changes: 71 additions & 0 deletions DDD.Base/DDD.Base.csproj
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>
44 changes: 44 additions & 0 deletions DDD.Base/Domain/AggregateRoot.cs
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);
}
}
}
42 changes: 42 additions & 0 deletions DDD.Base/Domain/AgregateId.cs
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;
}
}
}
14 changes: 14 additions & 0 deletions DDD.Base/Domain/DomainOperationException.cs
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;
}
}
}
7 changes: 7 additions & 0 deletions DDD.Base/Domain/Entity.cs
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; }
}
}
Loading

0 comments on commit 6930471

Please sign in to comment.