コード例 #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="PasteAsCS" /> class.
        ///     Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="codeConversion">Instance of the code converter, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private PasteAsCS(CodeConverterPackage package, CodeConversion codeConversion,
                          OleMenuCommandService commandService)
        {
            this.package    = package ?? throw new ArgumentNullException(nameof(package));
            _codeConversion = codeConversion;
            commandService  = commandService ?? throw new ArgumentNullException(nameof(commandService));

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = package.CreateCommand(CodeEditorMenuItemCallbackAsync, menuCommandID);

            menuItem.BeforeQueryStatus += MainEditMenuItem_BeforeQueryStatusAsync;
            commandService.AddCommand(menuItem);
        }