/// <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 MenuItemCallback(object sender, EventArgs e)
        {
            var ramlScaffoldUpdater  = RamlScaffoldServiceBase.GetRamlScaffoldService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
            var ramlChooserViewModel = new RamlChooserViewModel();

            ramlChooserViewModel.Load(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider, ramlScaffoldUpdater.AddContract, "Add RAML Contract", true, Settings.Default.RAMLExchangeUrl);
            dynamic settings = new ExpandoObject();

            settings.Height = 600;

            AmfToolsPackage.WindowManager.ShowDialog(ramlChooserViewModel, null, settings);
        }
Ejemplo n.º 2
0
        /// <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 async void Execute(object sender, EventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            await ChangeCommandStatusAsync(menuCommandID, false);

            // Get the file path
            uint         itemid;
            IVsHierarchy hierarchy;

            if (!IsSingleProjectItemSelection(out hierarchy, out itemid))
            {
                return;
            }
            string ramlFilePath;

            ((IVsProject)hierarchy).GetMkDocument(itemid, out ramlFilePath);

            var refFilePath = InstallerServices.GetRefFilePath(ramlFilePath);


            var editorModel = new RamlPropertiesEditorViewModel();

            editorModel.Load(refFilePath, RAML.Tools.Properties.Settings.Default.ContractsFolderName, RAML.Tools.Properties.Settings.Default.ApiReferencesFolderName);
            AMFToolsPackage.WindowManager.ShowDialog(editorModel);

            //var frm = new RamlPropertiesEditor();
            //frm.Load(refFilePath, RAML.Tools.Properties.Settings.Default.ContractsFolderName, RAML.Tools.Properties.Settings.Default.ApiReferencesFolderName);
            //var result = frm.ShowDialog();
            if (editorModel.WasSaved)
            {
                if (IsServerSide(ramlFilePath))
                {
                    var ramlScaffoldUpdater = RamlScaffoldServiceBase.GetRamlScaffoldService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
                    ramlScaffoldUpdater.UpdateRaml(ramlFilePath);
                }
                else
                {
                    var templatesManager    = new TemplatesManager();
                    var ramlFolder          = Path.GetDirectoryName(ramlFilePath).TrimEnd(Path.DirectorySeparatorChar);
                    var generatedFolderPath = ramlFolder.Substring(0, ramlFolder.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                    if (!templatesManager.ConfirmWhenIncompatibleClientTemplate(generatedFolderPath))
                    {
                        return;
                    }

                    await RegenerateClientCodeAsync(ramlFilePath);
                }
            }

            await ChangeCommandStatusAsync(menuCommandID, true);
        }
Ejemplo n.º 3
0
        /// <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.ThrowIfNotOnUIThread();

            var ramlScaffoldUpdater  = RamlScaffoldServiceBase.GetRamlScaffoldService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
            var ramlChooserViewModel = new RamlChooserViewModel();

            ramlChooserViewModel.Load(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider, ramlScaffoldUpdater.AddContract, "Add RAML/OAS Contract",
                                      true, RAML.Tools.Properties.Settings.Default.RAMLExchangeUrl);
            dynamic settings = new ExpandoObject();

            settings.Height = 600;

            AMFToolsPackage.WindowManager.ShowDialog(ramlChooserViewModel, null, settings);
        }