/// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(
                async() => {
                try
                {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    var dte = await ServiceProvider.GetServiceAsync(typeof(DTE)) as DTE;
                    Assumes.Present(dte);
                    var dteWrapper = new DteWrapper(dte);

                    if (dteWrapper.HasNoSelectedItems)
                    {
                        ShowWarningMessage(NO_FOLDER_OR_PROJECT_SELECTED_ERROR_MESSAGE);
                        return;
                    }

                    CreateMessageBasedOnUserSettings(dteWrapper);
                }
                catch (Exception ex)
                {
                    EnsureWaitDialogClosed();
                    ShowErrorMessage(ex.Message);
                }
            }
                );
        }
        private void CreateMessageBasedOnUserSettings(DteWrapper dteWrapper)
        {
            var storedSettings        = mediatrSettingsStoreManager.GetAllSettingsByProject(dteWrapper.SelectedProject);
            var messageSettingsWindow = new MediatrMessageSettingsWindow(storedSettings);
            var windowResult          = WindowHelper.ShowModal(messageSettingsWindow);

            if (WindowResultSucceeded(windowResult))
            {
                waitDialog.StartWaitDialog(
                    "Creating MeditR message...",
                    "Please wait...",
                    null,
                    0,
                    "MeditR message creating...",
                    0,
                    false,
                    true
                    );

                var mediatRMessageCreateModel = messageSettingsWindow.GetCreateMessageModel();
                CreateMediatrMessage(dteWrapper, mediatRMessageCreateModel);
                mediatrSettingsStoreManager.SaveUserSettigs(dteWrapper.SelectedProject, mediatRMessageCreateModel);

                waitDialog.EndWaitDialog();
            }
        }
Ejemplo n.º 3
0
        bool ProjectTypeMatch(NavigateItem item)
        {
            DteWrapper  wrapper = new DteWrapper(dte);
            ProjectType type    = wrapper.GetProjectType();

            return(!type.Conflicts(item.ProjectType));
        }
Ejemplo n.º 4
0
        bool ProjectTypeMatch(NavigateItem item)
        {
            DteWrapper  wrapper = new DteWrapper(dte);
            ProjectType type    = wrapper.GetProjectType();

            return((type != ProjectType.NoPlatform || type != ProjectType.Unknown) && wrapper.GetProjectType() == item.ProjectType);
        }
        private ProjectItems GetOrCreateFolderProjectItems(DteWrapper dteWrapper, CreateMessage model)
        {
            if (!model.ShouldCreateFolder)
            {
                return(dteWrapper.SelectedItemProjectItems);
            }

            var folderItem = dteWrapper.SelectedItemProjectItems.AddFolder(model.InputFileName);

            return(folderItem.ProjectItems);
        }
        private void CreateMediatrMessage(DteWrapper dteWrapper, CreateMessage model)
        {
            var folderProjectItems = GetOrCreateFolderProjectItems(dteWrapper, model);

            var codeClass = CreateMessageRequest(folderProjectItems, model, dteWrapper.DefaultClassTemplate);

            if (model.OneFileStyle)
            {
                if (model.OneClassStyle)
                {
                    CreateMessageRequestHandlerInRequestClass(codeClass, model);
                }
                else
                {
                    CreateMessageRequestHandlerInRequestFile(codeClass, model);
                }
            }
            else
            {
                CreateMessageRequestHandlerInNewFile(folderProjectItems, model, dteWrapper.DefaultClassTemplate);
            }

            if (model.ShouldCreateViewModel)
            {
                CreateViewModel(folderProjectItems, model, dteWrapper.DefaultClassTemplate);
            }

            if (model.ShouldCreateValidationFile)
            {
                CreateRequestValidator(folderProjectItems, model, dteWrapper.DefaultClassTemplate);
            }

            if (model.ShouldCreateAutomapperFile)
            {
                CreateAutoMapperProfile(folderProjectItems, model, dteWrapper.DefaultClassTemplate);
            }

            dteWrapper.SelectedProject.Save();
        }