Skip to content

Commit

Permalink
(GH-198) pass configuration in messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed May 29, 2016
1 parent 026df76 commit af4bf2f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/chocolatey/infrastructure.app/events/PostRunMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@

namespace chocolatey.infrastructure.app.events
{
using configuration;
using infrastructure.commands;
using infrastructure.events;

public class PostRunMessage : IMessage
{
public ChocolateyConfiguration Configuration { get; private set; }

public PostRunMessage(ChocolateyConfiguration configuration)
{
this.Configuration = configuration;
}
}

public class PostRunMessage<TCommand> : IMessage where TCommand : ICommand
{
public TCommand Command { get; private set; }
public ChocolateyConfiguration Configuration { get; set; }
public object[] State { get; private set; }

public PostRunMessage(TCommand command, object[] state)
public PostRunMessage(TCommand command, ChocolateyConfiguration configuration, object[] state)
{
Command = command;
this.Configuration = configuration;
State = state;
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/chocolatey/infrastructure.app/events/PreRunMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@

namespace chocolatey.infrastructure.app.events
{
using configuration;
using infrastructure.commands;
using infrastructure.events;

public class PreRunMessage : IMessage
{
public ChocolateyConfiguration Configuration { get; private set; }

public PreRunMessage(ChocolateyConfiguration configuration)
{
this.Configuration = configuration;
}
}

public class PreRunMessage<TCommand> : IMessage where TCommand : ICommand
{
public TCommand Command { get; private set; }
public ChocolateyConfiguration Configuration { get; private set; }
public object[] State { get; private set; }

public PreRunMessage(TCommand command, object[] state)
public PreRunMessage(TCommand command, ChocolateyConfiguration configuration, object[] state)
{
Command = command;
this.Configuration = configuration;
State = state;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/chocolatey/infrastructure.app/runners/GenericRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void run(ChocolateyConfiguration config, Container container, bool isCons
fail_when_license_is_missing_or_invalid_if_requested(config);


EventManager.publish(new PreRunMessage());
EventManager.publish(new PreRunMessage(config));

var command = find_command(config, container, isConsole, parseArgs);
if (command != null)
Expand All @@ -153,7 +153,7 @@ public void run(ChocolateyConfiguration config, Container container, bool isCons
command.run(config);
}

EventManager.publish(new PostRunMessage());
EventManager.publish(new PostRunMessage(config));

foreach (var task in tasks.or_empty_list_if_null())
{
Expand Down

0 comments on commit af4bf2f

Please sign in to comment.