Exemplo n.º 1
0
        /// <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="fileSystem">The file system from which referenced files are loaded. Use a ChrootFileSystem to specify the base directory for relative paths.</param>
        public ProjectDescriptor(XmlElement element, IReadOnlyFileSystem fileSystem)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

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

            LoadElementChildren(element, fileSystem);
        }
Exemplo n.º 2
0
        static Action <FileTemplateResult> ReadAction(XmlElement el)
        {
            switch (el.Name)
            {
            case "RunCommand":
                if (el.HasAttribute("path"))
                {
                    try {
                        ICommand command = (ICommand)SD.AddInTree.BuildItem(el.GetAttribute("path"), null);
                        return(command.Execute);
                    } catch (TreePathNotFoundException ex) {
                        MessageService.ShowWarning(ex.Message + " - in " + el.OwnerDocument.DocumentElement.GetAttribute("fileName"));
                        return(null);
                    }
                }
                else
                {
                    ProjectTemplateImpl.WarnAttributeMissing(el, "path");
                    return(null);
                }

            default:
                ProjectTemplateImpl.WarnObsoleteNode(el, "Unknown action element is ignored");
                return(null);
            }
        }
Exemplo n.º 3
0
        static Action <object> ReadAction(XmlElement el)
        {
            switch (el.Name)
            {
            case "RunCommand":
                if (el.HasAttribute("path"))
                {
                    string path = el.GetAttribute("path");
                                                #if DEBUG
                    ICommand command = (ICommand)SD.AddInTree.BuildItem(path, null);
                    if (command == null)
                    {
                        throw new TemplateLoadException("Unknown create action " + path);
                    }
                                                #endif
                    return(project => {
                                                        #if !DEBUG
                        ICommand command = (ICommand)SD.AddInTree.BuildItem(path, null);
                                                        #endif
                        if (command != null)
                        {
                            command.Execute(project);
                        }
                    });
                }
                else
                {
                    ProjectTemplateImpl.WarnAttributeMissing(el, "path");
                    return(null);
                }

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