/// <summary>
        /// Creates a project descriptor for the project node specified by the xml element.
        /// </summary>
        /// <param name="element">The &lt;Project&gt; node of the xml template file.</param>
        /// <param name="hintPath">The directory on which relative paths (e.g. for referenced files) are based.</param>
        public ProjectDescriptor(XmlElement element, string hintPath)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (hintPath == null)
            {
                throw new ArgumentNullException("hintPath");
            }

            if (element.HasAttribute("name"))
            {
                name = element.GetAttribute("name");
            }
            else
            {
                name = "${ProjectName}";
            }
            if (element.HasAttribute("directory"))
            {
                relativePath = element.GetAttribute("directory");
            }
            else
            {
                relativePath = ".";
            }
            languageName = element.GetAttribute("language");
            if (string.IsNullOrEmpty(languageName))
            {
                ProjectTemplate.WarnAttributeMissing(element, "language");
            }

            LoadElementChildren(element, hintPath);
        }
Example #2
0
        static Action <FileTemplateOptions> ReadAction(XmlElement el)
        {
            switch (el.Name)
            {
            case "RunCommand":
                if (el.HasAttribute("path"))
                {
                    try {
                        ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null);
                        return(fileCreateInformation => {
                            command.Owner = fileCreateInformation;
                            command.Run();
                        });
                    } catch (TreePathNotFoundException ex) {
                        MessageService.ShowWarning(ex.Message + " - in " + el.OwnerDocument.DocumentElement.GetAttribute("fileName"));
                        return(null);
                    }
                }
                else
                {
                    ProjectTemplate.WarnAttributeMissing(el, "path");
                    return(null);
                }

            default:
                ProjectTemplate.WarnObsoleteNode(el, "Unknown action element is ignored");
                return(null);
            }
        }
        static Action <IProject> ReadAction(XmlElement el)
        {
            switch (el.Name)
            {
            case "RunCommand":
                if (el.HasAttribute("path"))
                {
                    ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null);
                    return(project => {
                        command.Owner = project;
                        command.Run();
                    });
                }
                else
                {
                    ProjectTemplate.WarnAttributeMissing(el, "path");
                    return(null);
                }

            default:
                throw new TemplateLoadException("Unknown node in <CreateActions>: " + el.Name);
            }
        }
        static Action <IProject> ReadAction(XmlElement el)
        {
            switch (el.Name)
            {
            case "RunCommand":
                if (el.HasAttribute("path"))
                {
                    string path = el.GetAttribute("path");
                                                #if DEBUG
                    ICommand command = (ICommand)AddInTree.BuildItem(path, null);
                    if (command == null)
                    {
                        throw new TemplateLoadException("Unknown create action " + path);
                    }
                                                #endif
                    return(project => {
                                                        #if !DEBUG
                        ICommand command = (ICommand)AddInTree.BuildItem(path, null);
                                                        #endif
                        if (command != null)
                        {
                            command.Owner = project;
                            command.Run();
                        }
                    });
                }
                else
                {
                    ProjectTemplate.WarnAttributeMissing(el, "path");
                    return(null);
                }

            default:
                throw new TemplateLoadException("Unknown node in <CreateActions>: " + el.Name);
            }
        }