コード例 #1
0
        private Dictionary <string, string> PreHandleCustomItem(Dictionary <string, string> replacementsDictionary)
        {
            string templateFolder = UserOptionsHelper.GetOption <string>(UserOptionProperties.CustomTemplatesPath);

            _addFile = CustomTemplateHandler.ValidateTemplateFolder(templateFolder);
            if (!_addFile)
            {
                return(replacementsDictionary);
            }

            _addFile = CustomTemplateHandler.ValidateTemplateFile(templateFolder);
            if (!_addFile)
            {
                return(replacementsDictionary);
            }

            CustomTemplates templates = CustomTemplateHandler.GetTemplateConfig(templateFolder);

            if (templates == null)
            {
                _addFile = false;
                return(replacementsDictionary);
            }

            List <CustomTemplate> results = CustomTemplateHandler.GetTemplatesByLanguage(templates, "CSharp");

            if (results.Count == 0)
            {
                MessageBox.Show(Resource.MessageBox_AddCustomTemplate);
                _addFile = false;
                return(replacementsDictionary);
            }

            CustomTemplatePicker templatePicker = CustomTemplateHandler.GetCustomTemplate(results);

            if (templatePicker.SelectedTemplate == null)
            {
                _addFile = false;
                return(replacementsDictionary);
            }

            _customTemplate = templatePicker.SelectedTemplate;

            string content = CustomTemplateHandler.GetTemplateContent(templateFolder, _customTemplate, replacementsDictionary);

            replacementsDictionary.Add("$customtemplate$", content);

            return(replacementsDictionary);
        }
コード例 #2
0
        public static CustomTemplatePicker GetCustomTemplate(List <CustomTemplate> results)
        {
            CustomTemplatePicker templatePicker = new CustomTemplatePicker(results);
            bool?result = templatePicker.ShowModal();

            if (!result.HasValue || result.Value == false)
            {
                throw new WizardBackoutException();
            }

            if (templatePicker.SelectedTemplate == null)
            {
                OutputLogger.WriteToOutputWindow(Resource.ErrorMessage_NoSelectedTemplate, MessageType.Error);
            }

            return(templatePicker);
        }