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 RobotsMiddleware | |
{ | |
private readonly RequestDelegate _next; | |
private readonly ILogger _logger; | |
public RobotsMiddleware(RequestDelegate next, ILoggerFactory loggerFactory) | |
{ | |
_next = next; | |
_logger = loggerFactory.CreateLogger<RobotsMiddleware>(); | |
} |
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
await ApplicationService.ExecuteAsync( // (await response options 4.2 vs 4.3 | |
eventStore, | |
command.AggregateId, | |
command.CorrelationId, | |
events => events.Rehydrate<AggregateState>(), //aggregate, fold, match | |
state => Aggregate.Handle(command, state), | |
log.AppendAsync, | |
locks, | |
timeoutHandler, | |
waitForLockRelease: false // 4.2 vs 4.3 |
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 EventProcessor | |
{ | |
private readonly IDictionary<IAggregateId, (Guid, SemaphoreSlim)> _locks; | |
private readonly Action<string> _logger; | |
private readonly List<(Type, Func<IEvent, Task>)> _h = new List<(Type, Func<IEvent, Task>)>(); | |
public EventProcessor(IDictionary<IAggregateId, (Guid, SemaphoreSlim)> locks) : this(locks, s => { }) | |
{} | |
public EventProcessor(IDictionary<IAggregateId, (Guid, SemaphoreSlim)> locks, Action<string> logger) |
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 Dispatcher<TMessage, TResult> | |
{ | |
private readonly IDictionary<Type, Func<TMessage, TResult>> _dictionary = new ConcurrentDictionary<Type, Func<TMessage, TResult>>(); | |
public void Register<T>(Func<T, TResult> func) where T : TMessage | |
=> _dictionary.Add(typeof(T), x => func((T)x)); | |
public TResult Dispatch(TMessage m) | |
{ | |
Func<TMessage, TResult> handler; |
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 Module | |
{ | |
public static Func<ICommand, Task> Run(CancellationToken token, Subject<IEvent> eventSubject, Action<string> logger) | |
{ | |
const string streamName = "the-stream"; | |
var commitLog = new MessageVaultClientAdapter(new MemoryClient(), logger); | |
var dispatcher = new Dispatcher<ICommand, Task>(); | |
var eventHandlers = new Dispatcher<IEvent, Task>(); | |
var checkpointWriter = new CheckpointWriterAdapter(new MemoryCheckpointReaderWriter()); | |
var repository = new InMemoryStateRepository<State>(); |
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 BroadcastToXXX : IBroadcast | |
{ | |
private readonly IConnectionManager _connectionManager; | |
public BroadcastToCorrelating(IConnectionManager connectionManager) | |
{ | |
_connectionManager = connectionManager; | |
} | |
public async Task WhenAsync(IEvent @event) |
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 BroadcastToCorrelating : IBroadcast | |
{ | |
private readonly IConnectionManager _connectionManager; | |
public BroadcastToCorrelating(IConnectionManager connectionManager) | |
{ | |
_connectionManager = connectionManager; | |
} | |
public async Task WhenAsync(IEvent @event) |
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 IServiceBus | |
{ | |
Task PublishAsync<T>(T message); | |
IDisposable Subscribe<T>(IObserver<T> handler,SubscriptionConfiguration configuration=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
var viewModel = WinJS.Class.define(function() { | |
// this is the constructor function | |
var self = this; | |
}, { | |
// object literal for methods and attributes on the "class" | |
}); | |
var observableViewModel = WinJS.Class.mix(viewModel, WinJS.Binding.mixin, WinJS.Binding.expandProperties(viewModel)); | |
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
autoLoadTests: function (e) { | |
var re = new RegExp("([^/]+\.html$)"); | |
var testUrl = e.detail.location.replace(re, QUnit.config.unitTestFileName); |