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
public class CurrentPortfolioProjection : | |
IHandle<AddedRealtyToPortfolio>, | |
IHandle<RemovedRealtyFromPortfolio> { | |
Func<PortfolioContext> _contextFactory; | |
public CurrentPortfolioProjection(Func<PortfolioContext> contextFactory) { | |
_contextFactory = contextFactory; | |
} |
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
public class CurrentPortfolioProjection : | |
IHandle<AddedRealtyToPortfolio>, | |
IHandle<RemovedRealtyFromPortfolio> { | |
IProjectionSqlOperations<CurrentPortfolioEntry> _operations; | |
public CurrentPortfolioProjection(IProjectionSqlOperations<CurrentPortfolioEntry> operations) { | |
_operations = operations; | |
} |
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
public class PushBasedProjectionSqlOperations<TProjection> : | |
IProjectionSqlOperations<TProjection> { | |
IObserver<ISqlStatement> _observer; | |
ISqlStatementFactory _factory; | |
public PushBasedProjectionSqlOperations( | |
IObserver<ISqlStatement> observer, | |
ISqlStatementFactory factory) { | |
_observer = observer; |
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
public class SqlStatementCollector : IObserver<ISqlStatement> { | |
List<ISqlStatement> _statements; | |
public SqlStatementCollector() { | |
_statements = new List<ISqlStatement>(); | |
} | |
public ISqlStatement[] CollectedStatements { | |
get { | |
return _statements.ToArray(); |
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
public class ThresholdedSqlStatementFlusher : IObserver<ISqlStatement> { | |
readonly int _threshold; | |
readonly ISqlConnectionTransactionFactory _connectionTransactionFactory; | |
readonly ISqlBatchWriterFactory _batchWriterFactory; | |
readonly List<ISqlStatement> _statements; | |
public ThresholdedSqlStatementFlusher( | |
int threshold, |
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
public class Video : VoodooMagic { | |
public static Video New(VideoId id, Title title, Date releaseDate) { | |
return new Video( | |
Events.NewVideo(id, title, releaseDate)); | |
} | |
Video(object initialEvent) { | |
ApplyEvent(initialEvent); | |
} |
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
// In its simplest form | |
public class VideoTape { | |
// as purely constructor injection of a "parent" | |
public VideoTape(Video video) { | |
_video = video; | |
} | |
} | |
public class VideoTape : IVideoObjectInheritor { | |
// as a hidden-from-the-public-eye method based injection |
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
public class RenovationPolicy { | |
public RenovationRequest FileRequestFor(Building building) { | |
if(building.WasBetween(10.YearsAgo(), 25.YearsAgo()).WhenConstructed()) { | |
//... | |
} | |
} | |
} | |
public class Building { | |
internal BuildingAgeConstraint WasBetween(Date lower, Date upper) { |
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
public interface IMessageBuilder { | |
object Build(); | |
} | |
public interface IEventBuilder : IMessageBuilder { | |
IMessageBuilder IdentifiedBy(Guid id, int version); | |
} | |
public abstract class AggregateRootEntity { | |
//... |
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
using System; | |
using System.Collections.Generic; | |
using System.Reactive; | |
using System.Reactive.Subjects; | |
namespace NaiveEventSourcing { | |
class Program { | |
static void Main(string[] args) { | |
var travelerRepository = new AlwaysNewTravelerRepository(); | |
var travelerService = new TravelerService(travelerRepository); |