private async void FactoryCreation(String factoryType) { var parameters = new Dictionary <string, string> { { "{NAMESPACE}", "BuiltDesignPatternsTest.FactoryTest.Shape" + factoryType }, { "{PARENT_OBJECT}", "Shape" } }; var shapes = new Dictionary <String, List <String> > { { "{OBJECT}", new List <string> { "Circle", "Square" } } }; var designPatternBuilder = new DesignPatternBuilder(_dpFileManager); var files = designPatternBuilder.BuildFromXml(factoryType + ".xml", parameters, shapes).Result; var folder = await _dpFileManager.GetApplicationStorageFolder("TestDrops"); foreach (var classInformation in files) { await _dpFileManager.CreateFile(classInformation.FileName, folder, classInformation.Content); var fileExits = _dpFileManager.FileExistsInFolder(classInformation.FileName, folder).Result; Assert.IsTrue(fileExits); } }
private async void SingletonBuilder(String type) { var classValues = new Dictionary <string, string> { { "{NAMESPACE}", "BuiltDesignPatternsTest.SingletonTest" }, { "{CLASS_NAME}", "My" + type } }; var designPatternBuilder = new DesignPatternBuilder(_dpFileManager); var classInformation = designPatternBuilder.BuildFromXml(type + ".xml", classValues, null).Result.First(); var folder = await _dpFileManager.GetApplicationStorageFolder("TestDrops"); await _dpFileManager.CreateFile(classInformation.FileName, folder, classInformation.Content); var fileExits = _dpFileManager.FileExistsInFolder(classInformation.FileName, folder).Result; Assert.IsTrue(fileExits); }
public async Task <IEnumerable <DesignPatternFile> > UpdateDesignPatterns(bool forceUpdate = false) { var fileExists = await _fileManager.FileExistsInFolder("DesignPatternsList.dsxml", _fileManager.GetDesignPatternsTemplatesPath()); if (!fileExists || forceUpdate) { return(await UpdateDesignPatternsFile()); } var readFileXml = await _fileManager.ReadFile("DesignPatternsList.dsxml", _fileManager.GetDesignPatternsTemplatesPath()); var designPatternsXml = XDocument.Parse(readFileXml); var designPatternsXmlCount = designPatternsXml.Descendants("DesignPattern").Count(); var designPatternsFilesCount = await GetDesignPatternsFiles(); if (designPatternsFilesCount.Count() != designPatternsXmlCount) { return(await UpdateDesignPatternsFile()); } var dpList = new List <DesignPatternFile>(); var i = 0; foreach (var dp in designPatternsXml.Descendants("DesignPattern")) { dpList.Add(new DesignPatternFile() { Id = i, DesignPatternName = dp.Descendants("Name").FirstOrDefault().Value, DesignPatternType = dp.Attribute("type").Value, Description = dp.Descendants("Description").FirstOrDefault().Value.Trim(), Path = dp.Descendants("Name").FirstOrDefault().Value.Replace(" ", "") + ".xml" }); i++; } return(dpList); }