mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-31 07:52:37 +01:00
less reflectionee Command publishing.
This commit is contained in:
parent
c122502634
commit
587eba6324
@ -76,23 +76,18 @@ namespace NzbDrone.Common.Messaging
|
|||||||
|
|
||||||
_logger.Trace("Publishing {0}", command.GetType().Name);
|
_logger.Trace("Publishing {0}", command.GetType().Name);
|
||||||
|
|
||||||
var handler = _serviceFactory.Build(handlerContract);
|
var handler = (IExecute<TCommand>)_serviceFactory.Build(handlerContract);
|
||||||
|
|
||||||
_logger.Debug("{0} -> {1}", command.GetType().Name, handler.GetType().Name);
|
_logger.Debug("{0} -> {1}", command.GetType().Name, handler.GetType().Name);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
handlerContract.GetMethod("Execute").Invoke(handler, new object[] { command });
|
handler.Execute(command);
|
||||||
PublishEvent(new CommandCompletedEvent(command));
|
PublishEvent(new CommandCompletedEvent(command));
|
||||||
}
|
}
|
||||||
catch (TargetInvocationException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PublishEvent(new CommandFailedEvent(command, e));
|
PublishEvent(new CommandFailedEvent(command, e));
|
||||||
|
|
||||||
if (e.InnerException != null)
|
|
||||||
{
|
|
||||||
throw e.InnerException;
|
|
||||||
}
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -108,9 +103,8 @@ namespace NzbDrone.Common.Messaging
|
|||||||
var commandType = _serviceFactory.GetImplementations(typeof(ICommand))
|
var commandType = _serviceFactory.GetImplementations(typeof(ICommand))
|
||||||
.Single(c => c.FullName.Equals(commandTypeName, StringComparison.InvariantCultureIgnoreCase));
|
.Single(c => c.FullName.Equals(commandTypeName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
//json.net is better at creating objects
|
dynamic command = Json.Deserialize("{}", commandType);
|
||||||
var command = Json.Deserialize("{}", commandType);
|
PublishCommand(command);
|
||||||
PublishCommand((ICommand)command);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user