コード例 #1
0
        public static Task <ProjectTemplateIndex> GetProjectTemplates()
        {
            string url = GetOnlineTemplatesRoot() + "project-template-index.xml";
            var    up  = UpdateTemplateIndex(url, ProjectTemplateIndexFile, TimeSpan.FromDays(1));

            if (up != null)
            {
                return(up.ContinueWith(t => ProjectTemplateIndex.Load(ProjectTemplateIndexFile)));
            }
            else
            {
                return(Task.Factory.StartNew(() => ProjectTemplateIndex.Load(ProjectTemplateIndexFile)));
            }
        }
コード例 #2
0
        public static ProjectTemplateIndex Load(string file)
        {
            var doc = XDocument.Load(file);
            var idx = new ProjectTemplateIndex();

            var root = doc.Root;

            if (root.Name != "TemplateIndex")
            {
                throw new Exception(string.Format("Root element was {0}, expected '{1}'", root.Name, "ProjectTemplate"));
            }
            if ((int)root.Attribute("format") != FORMAT_VERSION)
            {
                throw new Exception("Invalid format version");
            }

            idx.MDVersion = (string)root.Attribute("version");

            return(idx);
        }