Skip to content

Instantly share code, notes, and snippets.

@ArnisL
Created October 19, 2011 22:02
Show Gist options
  • Save ArnisL/1299823 to your computer and use it in GitHub Desktop.
Save ArnisL/1299823 to your computer and use it in GitHub Desktop.
refactoring == joy
namespace Interreg.App.Audit.Application{
using Domain.Model.Applications;
public class ApplicationAudit:Audit{
public override void AttachHandlers(){
On<AttachmentAdded>(e=>e.Source.LogEvent(
"Attachment named '{0}' added".With(e.Attachment.Name)));
On<AttachmentRemoved>(e=>e.Source.LogEvent(
"Attachment named '{0}' removed".With(e.Attachment.Name)));
On<CommentsEdited>(e=>e.Source.LogEvent(
"Application comments edited"));
On<Registered>(e=>e.Source.LogEvent(
"Application registered"));
On<Updated>(e=>e.Source.LogEvent(
"Application form updated"));
On<Withdrawn>(e=>e.Source.LogEvent(
"Application withdrawn"));
}
}
}
//you look different
//http://www.youtube.com/watch?v=DOw62EREnCg
namespace Interreg.App.Audit.Application{
using Domain;
using Domain.Model.Applications;
using Domain.Model.Shared;
public class ApplicationAudit{
public class OnAttachmentAdded:IEventHandler<AttachmentAdded>{
public void Handle(AttachmentAdded e){
var msg="Attachment named '{0}' added".With(e.Attachment.Name);
e.Source.LogEvent(new LogEntry(msg));
}
}
public class OnAttachmentRemoved:IEventHandler<AttachmentRemoved>{
public void Handle(AttachmentRemoved e){
var msg="Attachment named '{0}' removed".With(e.Attachment.Name);
e.Source.LogEvent(new LogEntry(msg));
}
}
public class OnCommentsEdited:IEventHandler<CommentsEdited>{
public void Handle(CommentsEdited e){
e.Source.LogEvent(new LogEntry("Application comments edited"));
}
}
public class OnRegistered:IEventHandler<Registered>{
public void Handle(Registered e){
e.Source.LogEvent(new LogEntry("Application registered"));
}
}
public class OnUpdated:IEventHandler<Updated>{
public void Handle(Updated e){
e.Source.LogEvent(new LogEntry("Application form updated"));
}
}
public class OnWithdrawn:IEventHandler<Withdrawn>{
public void Handle(Withdrawn e){
e.Source.LogEvent(new LogEntry("Application withdrawn"));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment