@@ -228,9 +228,6 @@ private void RegisterFactories(IWindsorContainer container, Assembly[] assemblie
228
228
229
229
private static void RegisterSpecialFactories ( IWindsorContainer container )
230
230
{
231
- //container.Register(Component.For<IDeclarationFinderFactory>()
232
- // .ImplementedBy<DeclarationFinderFactory>()
233
- // .LifestyleSingleton());
234
231
container . Register ( Component . For < IFolderBrowserFactory > ( )
235
232
. ImplementedBy < DialogFactory > ( )
236
233
. LifestyleSingleton ( ) ) ;
@@ -558,19 +555,19 @@ private void RegisterCommands(IWindsorContainer container)
558
555
//note: convention: the registration name for commands is the type name, not the full type name.
559
556
//Otherwise, namespaces would get in the way when binding to the menu items.
560
557
RegisterCommandsWithPresenters ( container ) ;
561
-
562
- //var commandsForCommandMenuItems = Assembly.GetExecutingAssembly().GetTypes()
563
- // .Where(type => type.IsClass && typeof(ICommandMenuItem).IsAssignableFrom(type))
564
- // .Select(type => CommandNameFromCommandMenuName(type.Name))
565
- // .ToHashSet();
558
+
559
+ // assumption: All Commands (and CommandMenuItems by extension) are in the same assembly as CommandBase
560
+ var commandsForCommandMenuItems = Assembly . GetAssembly ( typeof ( CommandBase ) ) . GetTypes ( )
561
+ . Where ( type => type . IsClass && typeof ( ICommandMenuItem ) . IsAssignableFrom ( type ) )
562
+ . Select ( type => CommandNameFromCommandMenuName ( type . Name ) )
563
+ . ToHashSet ( ) ;
566
564
567
565
container . Register ( Classes . FromAssemblyContaining < CommandBase > ( )
568
566
. Where ( type => type . Namespace != null
569
567
&& type . Namespace . StartsWith ( typeof ( CommandBase ) . Namespace ?? string . Empty )
570
568
&& ( type . BaseType == typeof ( CommandBase ) || type . BaseType == typeof ( RefactorCommandBase ) )
571
569
&& type . Name . EndsWith ( "Command" )
572
- // FIXME something something commandsForCommandMenuItems ...
573
- && type . Assembly . GetTypes ( ) . Any ( menuItemType => menuItemType . Name == ( type . Name + "MenuItem" ) ) )
570
+ && commandsForCommandMenuItems . Contains ( type . Name ) )
574
571
. WithService . Self ( )
575
572
. WithService . Select ( new [ ] { typeof ( CommandBase ) } )
576
573
. LifestyleTransient ( )
0 commit comments