コード例 #1
0
        public async Task <DesignPatternFile> Parse(StorageFile file)
        {
            var readFile = await _fileManager.ReadFile(file.Name, await _fileManager.GetDesignPatternsTemplatesPath());

            var doc           = XDocument.Parse(readFile);
            var designPattern = doc.Descendants("DesignPattern").FirstOrDefault();

            if (designPattern == null)
            {
                throw new Exception("Design Pattern node not found in file " + file.Name);
            }

            var fileName     = designPattern.Attribute("name").Value;
            var type         = designPattern.Attribute("type").Value;
            var description  = designPattern.Descendants("Description").FirstOrDefault().Value;
            var modifiedDate = (await file.GetBasicPropertiesAsync()).DateModified;

            var dpFile = new DesignPatternFile
            {
                Description       = description,
                DesignPatternName = fileName,
                DesignPatternType = type,
                Path         = file.Name,
                ModifiedDate = modifiedDate
            };

            return(dpFile);
        }
コード例 #2
0
        public async Task <IEnumerable <DesignPatternParameter> > GetParametersFromDesignPattern(String patternPath)
        {
            var fileManager = new FileManager();
            var readFile    = await fileManager.ReadFile(patternPath, await fileManager.GetDesignPatternsTemplatesPath());

            var designPatternXml = XDocument.Parse(readFile);

            var parameters = designPatternXml.Descendants("Parameter");

            var patternParameters = from p in parameters
                                    select new DesignPatternParameter
            {
                Name        = p.Attribute("name").Value,
                Description = p.Attribute("description").Value,
                IsMultiple  =
                    p.Attribute("multiple") != null &&
                    Boolean.Parse(p.Attribute("multiple").Value)
            };

            return(patternParameters);
        }