Esempio n. 1
0
        public TemplateLibrary(string templatesRoot)
        {
            this._templatesRoot       = templatesRoot;
            this._templateDirectories = new Cache <TemplateType, string>(delegate(TemplateType type)
            {
                string directory = FubuCore.StringExtensions.AppendPath(this._templatesRoot, new string[]
                {
                    type.ToString().ToLowerInvariant()
                });
                TemplateLibrary.FileSystem.CreateDirectory(directory);
                return(directory);
            });
            GenericEnumerableExtensions.Each <TemplateType>(Enum.GetValues(typeof(TemplateType)).OfType <TemplateType>(), delegate(TemplateType x)
            {
                this._templateDirectories.FillDefault(x);
            });
            string graphFile = FubuCore.StringExtensions.AppendPath(templatesRoot, new string[]
            {
                TemplateGraph.FILE
            });

            if (File.Exists(graphFile))
            {
                this.Graph = TemplateGraph.Read(graphFile);
            }
        }
Esempio n. 2
0
        public static TemplateGraph Read(string file)
        {
            XmlDocument document = new XmlDocument();

            document.Load(file);
            TemplateGraph graph = new TemplateGraph();

            foreach (XmlElement element in document.DocumentElement.SelectNodes("category"))
            {
                ProjectCategory category = new ProjectCategory
                {
                    Type = element.GetAttribute("type")
                };
                foreach (XmlElement projectElement in element.SelectNodes("project"))
                {
                    category.Templates.Add(projectElement.BuildProjectTemplate());
                }
                graph._categories.Add(category);
            }
            return(graph);
        }