Exemplo n.º 1
0
        public CommandService(
            IShell app,
            MainThread mainThread,
            IEventStream eventStream,
            Selection selection,
            [ImportMany] IEnumerable <Lazy <IMenuCommand, MenuCommandMetadata> > commands,
            [ImportMany] IEnumerable <Lazy <ContentView, MenuCommandMetadata> > views)
        {
            var allCommands = commands.Concat(
                views
                .OrderBy(x => x.Metadata.Key)
                .Select(x =>
                        new Lazy <IMenuCommand, MenuCommandMetadata>(
                            () => new MenuCommandAdapter(x, app),
                            // We need a different metadata with a null context
                            // to convert the ContentView into a global command
                            new MenuCommandMetadata
            {
                DisplayName    = x.Metadata.DisplayName,
                Key            = x.Metadata.Key,
                Order          = x.Metadata.Order,
                DefaultVisible = true,
                ReportProgress = false
            })));

            foreach (var command in allCommands)
            {
                var key = Tuple.Create(command.Metadata.Key, command.Metadata.Context);

                if (!this.commands.TryGetValue(key, out var existingCommand) ||
                    existingCommand.Metadata.Order > command.Metadata.Order)
                {
                    this.commands[key] = command;
                }
            }

            this.mainThread  = mainThread;
            this.eventStream = eventStream;
            this.selection   = selection;
        }
Exemplo n.º 2
0
 public InstallPluginsCommand(IShell shell, IPluginManager plugins, MainThread mainThread)
 {
     this.shell      = shell;
     this.plugins    = plugins;
     this.mainThread = mainThread;
 }
Exemplo n.º 3
0
 public CommandExports(Lazy <IShell> app, MainThread mainThread)
 {
     this.app        = app;
     this.mainThread = mainThread;
 }