Пример #1
0
        public void ProjectItemFinishedGenerating(ProjectItem projectItem)
        {
            if (!_addFile)
            {
                return;
            }

            if (_crmProjectType != ProjectType.CustomItem)
            {
                return;
            }

            if (_customTemplate == null)
            {
                return;
            }

            var project = projectItem.ContainingProject;

            CustomTemplateHandler.AddTemplateReferences(_customTemplate, project);

            CustomTemplateHandler.InstallTemplateNuGetPackages(_customTemplate, project);

            if (!string.IsNullOrEmpty(_customTemplate.FileName))
            {
                projectItem.Name = _customTemplate.FileName;
            }
        }
Пример #2
0
        private Dictionary <string, string> PreHandleCustomItem(Dictionary <string, string> replacementsDictionary)
        {
            var templateFolder = UserOptionsHelper.GetOption <string>(UserOptionProperties.CustomTemplatesPath);

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

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

            var templates = CustomTemplateHandler.GetTemplateConfig(templateFolder);

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

            var results = CustomTemplateHandler.GetTemplatesByLanguage(templates, "CSharp");

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

            var templatePicker = CustomTemplateHandler.GetCustomTemplate(results);

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

            _customTemplate = templatePicker.SelectedTemplate;

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

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

            return(replacementsDictionary);
        }