Exemple #1
0
        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);
            }
        }
Exemple #2
0
        private async Task <IEnumerable <DesignPatternFile> > UpdateDesignPatternsFile()
        {
            var designPatternFiles = new List <DesignPatternFile>();

            try
            {
                var designPatternsXml = new XDocument(
                    new XDeclaration("1.0", "utf-8", "yes"),
                    new XElement("DesignPatterns")
                    );
                var files = await GetDesignPatternsFiles();

                var i = 0;
                foreach (var f in files)
                {
                    var readFile = await _fileManager.ReadFile(f.Name, await _fileManager.GetDesignPatternsTemplatesPath());

                    var doc           = XDocument.Parse(readFile);
                    var designPattern = doc.Descendants("DesignPattern").FirstOrDefault();
                    var fileName      = designPattern.Attribute("name").Value;
                    var type          = designPattern.Attribute("type").Value;
                    var description   = designPattern.Descendants("Description").FirstOrDefault();
                    var modifiedDate  = (await f.GetBasicPropertiesAsync()).DateModified;

                    var xmlFile = new XElement("DesignPattern",
                                               new XElement("Name", fileName,
                                                            new XAttribute("modifiedDate", modifiedDate)),
                                               new XElement("Description", description.Value.Trim()),
                                               new XElement("type", type));
                    designPatternsXml.Element("DesignPatterns").Add(xmlFile);

                    var designPatternFile = new DesignPatternFile
                    {
                        Id                = i,
                        Description       = description.Value.Trim(),
                        DesignPatternName = fileName,
                        DesignPatternType = type,
                        Path              = f.Name
                    };
                    designPatternFiles.Add(designPatternFile);
                    i++;
                }
                await _fileManager.CreateFile("DesignPatternsList.dsxml", await _fileManager.GetDesignPatternsTemplatesPath(),
                                              designPatternsXml.ToString());
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }


            return(designPatternFiles);
        }
Exemple #3
0
        public void CreateNewDesignPattern()
        {
            var doc = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XElement("DesignPattern",
                             new XAttribute("name", "PatternTest"),
                             new XElement("Description", "Blablabla"),
                             new XAttribute("type", "Test"))
                );

            _designPattensFileManager.CreateFile("PatternTest.xml",
                                                 _designPatternsTemplatesPath, doc.ToString());

            UpdateDesignPatternsTest();

            _designPattensFileManager.DeleteFile("PatternTest.xml",
                                                 _designPatternsTemplatesPath);
            UpdateDesignPatternsTest();
        }
        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);
        }