Remove autofac workaround

We are now done with the integration of the new autofac, there
is no need for these workaround anymore.

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-04-26 14:11:57 -07:00
parent 87c17e2f6a
commit 64f9c5c140
2 changed files with 6 additions and 25 deletions

View File

@@ -12,12 +12,9 @@ namespace Orchard.Commands {
if (!registration.Services.Contains(new TypedService(typeof(ICommandHandler))))
return;
// Workaround autofac integration: module registration is currently run twice...
if (!registration.Metadata.ContainsKey(typeof(CommandHandlerDescriptor).FullName)) {
var builder = new CommandHandlerDescriptorBuilder();
var descriptor = builder.Build(registration.Activator.LimitType);
registration.Metadata.Add(typeof (CommandHandlerDescriptor).FullName, descriptor);
}
var builder = new CommandHandlerDescriptorBuilder();
var descriptor = builder.Build(registration.Activator.LimitType);
registration.Metadata.Add(typeof(CommandHandlerDescriptor).FullName, descriptor);
}
}
}

View File

@@ -15,11 +15,8 @@ namespace Orchard.Commands {
public void Execute(CommandParameters parameters) {
var matches = MatchCommands(parameters);
// Workaround autofac integration: module registration is currently run twice...
//if (matches.Count() == 1) {
// var match = matches.Single();
if (matches.Count() == 1 || matches.Count() == 2) {
var match = matches.First();
if (matches.Count() == 1) {
var match = matches.Single();
match.CommandHandlerFactory().Execute(match.Context);
}
else if (matches.Any()) {
@@ -31,10 +28,7 @@ namespace Orchard.Commands {
}
public IEnumerable<CommandDescriptor> GetCommandDescriptors() {
return _handlers
.SelectMany(h => GetDescriptor(h.Metadata).Commands)
// Workaround autofac integration: module registration is currently run twice...
.Distinct(new CommandsComparer());
return _handlers.SelectMany(h => GetDescriptor(h.Metadata).Commands);
}
private IEnumerable<Match> MatchCommands(CommandParameters parameters) {
@@ -78,15 +72,5 @@ namespace Orchard.Commands {
public CommandContext Context { get; set; }
public Func<ICommandHandler> CommandHandlerFactory { get; set; }
}
public class CommandsComparer : IEqualityComparer<CommandDescriptor> {
public bool Equals(CommandDescriptor x, CommandDescriptor y) {
return x.MethodInfo.Equals(y.MethodInfo);
}
public int GetHashCode(CommandDescriptor obj) {
return obj.MethodInfo.GetHashCode();
}
}
}
}