From 64f9c5c1404751354dc4ee11a120e07b9b407005 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 26 Apr 2010 14:11:57 -0700 Subject: [PATCH] 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 --- src/Orchard/Commands/CommandModule.cs | 9 +++----- src/Orchard/Commands/DefaultCommandManager.cs | 22 +++---------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/Orchard/Commands/CommandModule.cs b/src/Orchard/Commands/CommandModule.cs index 442111f62..c857232b5 100644 --- a/src/Orchard/Commands/CommandModule.cs +++ b/src/Orchard/Commands/CommandModule.cs @@ -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); } } } diff --git a/src/Orchard/Commands/DefaultCommandManager.cs b/src/Orchard/Commands/DefaultCommandManager.cs index 56b84a2ce..f16642822 100644 --- a/src/Orchard/Commands/DefaultCommandManager.cs +++ b/src/Orchard/Commands/DefaultCommandManager.cs @@ -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 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 MatchCommands(CommandParameters parameters) { @@ -78,15 +72,5 @@ namespace Orchard.Commands { public CommandContext Context { get; set; } public Func CommandHandlerFactory { get; set; } } - - public class CommandsComparer : IEqualityComparer { - public bool Equals(CommandDescriptor x, CommandDescriptor y) { - return x.MethodInfo.Equals(y.MethodInfo); - } - - public int GetHashCode(CommandDescriptor obj) { - return obj.MethodInfo.GetHashCode(); - } - } } }