예제 #1
0
        private void ImplementContractCallback(object sender, EventArgs e)
        {
            ChangeImplementContractCommandStatus(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     = Path.Combine(Path.GetDirectoryName(ramlFilePath), Path.GetFileNameWithoutExtension(ramlFilePath) + ".ref");
            var targetNamespace = RamlReferenceReader.GetRamlNamespace(refFilePath);

            try
            {
                var scaffolder = new RamlScaffoldService(new T4Service(ServiceProvider.GlobalProvider),
                                                         ServiceProvider.GlobalProvider);
                scaffolder.Scaffold(ramlFilePath, targetNamespace, Path.GetFileName(ramlFilePath));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }

            ChangeImplementContractCommandStatus(true);
        }
        private void AddRamlContractCallback(object sender, EventArgs e)
        {
            var ramlScaffoldUpdater = new RamlScaffoldService(new T4Service(ServiceProvider.GlobalProvider), ServiceProvider.GlobalProvider);
            var frm = new RamlChooser(ServiceProvider.GlobalProvider, ramlScaffoldUpdater.AddContract, "Add RAML Contract", true, Settings.Default.RAMLExchangeUrl);

            frm.ShowDialog();
        }
        private void AddRamlContractCallback(object sender, EventArgs e)
        {
            var ramlScaffoldUpdater  = new RamlScaffoldService(new T4Service(ServiceProvider.GlobalProvider), ServiceProvider.GlobalProvider);
            var ramlChooserViewModel = new RamlChooserViewModel();

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

            settings.Height = 570;
            windowManager.ShowDialog(ramlChooserViewModel, null, settings);
            //var frm = new RamlChooserView(ServiceProvider.GlobalProvider, ramlScaffoldUpdater.AddContract, "Add RAML Contract", true, Settings.Default.RAMLExchangeUrl);
            //frm.ShowDialog();
        }
        private static void ScaffoldMainRamlFiles(IEnumerable <string> ramlFiles)
        {
            var globalProvider = ServiceProvider.GlobalProvider;
            var service        = new RamlScaffoldService(new T4Service(globalProvider), ServiceProvider.GlobalProvider);

            foreach (var ramlFile in ramlFiles)
            {
                var refFilePath     = InstallerServices.GetRefFilePath(ramlFile);
                var useAsyncMethods = RamlReferenceReader.GetRamlUseAsyncMethods(refFilePath);
                var targetNamespace = RamlReferenceReader.GetRamlNamespace(refFilePath);
                service.Scaffold(ramlFile, targetNamespace, Path.GetFileName(ramlFile), useAsyncMethods);
            }
        }
        private void EditRamlPropertiesCallback(object sender, EventArgs e)
        {
            ChangeCommandStatus(editRamlPropertiesCmdId, 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, Settings.Default.ContractsFolderName, Settings.Default.ApiReferencesFolderName);
            windowManager.ShowDialog(editorModel);

            //var frm = new RamlPropertiesEditor();
            //frm.Load(refFilePath, Settings.Default.ContractsFolderName, Settings.Default.ApiReferencesFolderName);
            //var result = frm.ShowDialog();
            if (editorModel.WasSaved)
            {
                if (IsServerSide(ramlFilePath))
                {
                    var ramlScaffoldUpdater = new RamlScaffoldService(new T4Service(ServiceProvider.GlobalProvider), 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;
                    }

                    var dte = (DTE2)GetService(typeof(SDTE));
                    dte.ExecuteCommand("Project.RunCustomTool");
                }
            }

            ChangeCommandStatus(editRamlPropertiesCmdId, true);
        }
예제 #6
0
        private static void ScaffoldMainRamlFiles(IEnumerable <string> ramlFiles)
        {
            var globalProvider = ServiceProvider.GlobalProvider;
            var service        = new RamlScaffoldService(new T4Service(globalProvider), ServiceProvider.GlobalProvider);

            foreach (var ramlFile in ramlFiles)
            {
                var refFilePath = InstallerServices.GetRefFilePath(ramlFile);
                var includeApiVersionInRoutePrefix = RamlReferenceReader.GetRamlIncludeApiVersionInRoutePrefix(refFilePath);
                var parameters = new RamlChooserActionParams(ramlFile, ramlFile, null, null, Path.GetFileName(ramlFile),
                                                             RamlReferenceReader.GetRamlNamespace(refFilePath), null)
                {
                    UseAsyncMethods = RamlReferenceReader.GetRamlUseAsyncMethods(refFilePath),
                    IncludeApiVersionInRoutePrefix = includeApiVersionInRoutePrefix,
                    ModelsFolder = RamlReferenceReader.GetModelsFolder(refFilePath),
                    ImplementationControllersFolder = RamlReferenceReader.GetImplementationControllersFolder(refFilePath),
                    AddGeneratedSuffixToFiles       = RamlReferenceReader.GetAddGeneratedSuffix(refFilePath)
                };
                service.Scaffold(ramlFile, parameters);
            }
        }
        private void UpdateRamlContractCallback(object sender, EventArgs e)
        {
            ChangeCommandStatus(updateRamlContractCommandId, 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 ramlScaffoldUpdater = new RamlScaffoldService(new T4Service(ServiceProvider.GlobalProvider), ServiceProvider.GlobalProvider);

            ramlScaffoldUpdater.UpdateRaml(ramlFilePath);

            ChangeCommandStatus(updateRamlContractCommandId, true);
        }