This file contains hidden or 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
import sequtils | |
let | |
child_steps = toSeq(readLine(stdin).items) | |
var | |
cx, cy, furthest = 0 | |
proc dist(): int = max(abs(cx), abs(cy)) |
This file contains hidden or 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.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Day11 | |
{ | |
class Program |
This file contains hidden or 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.IO; | |
using System.Linq; | |
namespace Day7 | |
{ | |
public class Node | |
{ | |
public string Name { get; set; } |
This file contains hidden or 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
service.AddInterceptor(new ValidateCommandInterceptor()); |
This file contains hidden or 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 CreateNewNoteValidator : AbstractValidator<CreateNewNote> | |
{ | |
public CreateNewNoteValidator() | |
{ | |
RuleFor(command => command.NoteId).NotEqual(Guid.Empty); | |
RuleFor(cmd => cmd.Text).Length(1, 140); | |
} | |
} |
This file contains hidden or 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
[Validator(typeof (CreateNewNoteValidator))] | |
[MapsToAggregateRootConstructor("MyNotes.Domain.Note, MyNotes.Domain")] | |
public class CreateNewNote : CommandBase | |
{ | |
public CreateNewNote() {} | |
public CreateNewNote(Guid noteId, string text) | |
{ | |
NoteId = noteId; | |
Text = text; |
This file contains hidden or 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 ValidateCommandInterceptor : ICommandServiceInterceptor | |
{ | |
private readonly IValidatorFactory _factory; | |
private readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | |
public ValidateCommandInterceptor(IValidatorFactory validatorFactory = null) | |
{ | |
_factory = validatorFactory ?? new AttributedValidatorFactory(); | |
} |
This file contains hidden or 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
/// <summary> | |
/// Executes the command. | |
/// </summary> | |
/// <param name="command">The command to execute.</param> | |
/// <returns>The aggregateroot of type <typeparamref name="TAggRoot"/> on which we executed the command.</returns> | |
void ICommandExecutor<TCommand>.Execute(TCommand command) | |
{ | |
var factory = NcqrsEnvironment.Get<IUnitOfWorkFactory>(); | |
using (var work = factory.CreateUnitOfWork(command.CommandIdentifier)) | |
{ |