GetTemplateList() 공개 메소드

public GetTemplateList ( ) : string[]
리턴 string[]
예제 #1
0
        public void Create(string ProductName)
        {
            string version       = GetTemplateVersion();
            string baseNamespace = "FX.Mobile.DeveloperTools.Templates" + "." + version + ".";

            var template      = new TemplateManager();
            var templateFiles = template.GetTemplateList();

            int total = 0;
            int count = 1;

            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                {
                    total++;
                }
            }

            if (ProductCreateInitializing != null)
            {
                ProductCreateInitializing(this, new ProductCreateEventArgs {
                    Count = 0, CurrentFile = string.Empty, Total = total
                });
            }

            var replacements = new List <StringReplacement>();

            replacements.Add(new StringReplacement {
                Pattern = "[MODULE:Custom]", Value = ProductName
            });
            replacements.Add(new StringReplacement {
                Pattern = "[MODULE-LC:Custom]", Value = ProductName.ToLower()
            });

            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                {
                    var fileContents = template.GetTemplate(templateFile, replacements);
                    var fileName     = templateFile.Replace(baseNamespace, "");

                    var filePath = Path.Combine(MobilePath, @"products\");
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    filePath = Path.Combine(filePath, "argos-" + ProductName.ToLower());
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    //check if sub directory
                    var parts = fileName.Split('.');
                    if (parts.Length > 2)
                    {
                        for (int i = 0; i < parts.Length - 2; i++)
                        {
                            filePath = Path.Combine(filePath, parts[i]);
                            if (!Directory.Exists(filePath))
                            {
                                Directory.CreateDirectory(filePath);
                            }

                            fileName = fileName.Replace(parts[i] + ".", "");
                        }
                    }

                    if (fileName == "build-custom.cmd")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = MobilePath;
                    }
                    if (fileName == "index-dev-custom.html")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = Path.Combine(MobilePath, @"products\argos-saleslogix\");
                        if (!Directory.Exists(filePath))
                        {
                            Directory.CreateDirectory(filePath);
                        }
                    }

                    if (ProductCreateProgress != null)
                    {
                        ProductCreateProgress(this, new ProductCreateEventArgs {
                            Count = count, CurrentFile = fileName, Total = total
                        });
                    }

                    count++;

                    using (var writer = new StreamWriter(Path.Combine(filePath, fileName)))
                    {
                        writer.Write(fileContents);
                    }
                }
            }

            Program.Path = MobilePath;
            CreateIndexFile();

            if (ProductCreateComplete != null)
            {
                ProductCreateComplete(this, new ProductCreateEventArgs {
                    Count = count, CurrentFile = string.Empty, Total = total
                });
            }
        }
        public void Create(string ProductName)
        {
            string version = GetTemplateVersion();
            string baseNamespace = "FX.Mobile.DeveloperTools.Templates" + "." + version + ".";

            var template = new TemplateManager();
            var templateFiles = template.GetTemplateList();

            int total = 0;
            int count = 1;
            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                    total++;
            }

            if (ProductCreateInitializing != null)
                ProductCreateInitializing(this, new ProductCreateEventArgs { Count = 0, CurrentFile = string.Empty, Total = total });

            var replacements = new List<StringReplacement>();
            replacements.Add(new StringReplacement { Pattern = "[MODULE:Custom]", Value = ProductName });
            replacements.Add(new StringReplacement { Pattern = "[MODULE-LC:Custom]", Value = ProductName.ToLower() });

            foreach (var templateFile in templateFiles)
            {
                if (templateFile.StartsWith(baseNamespace))
                {
                    var fileContents = template.GetTemplate(templateFile, replacements);
                    var fileName = templateFile.Replace(baseNamespace, "");

                    var filePath = Path.Combine(MobilePath, @"products\");
                    if (!Directory.Exists(filePath))
                        Directory.CreateDirectory(filePath);

                    filePath = Path.Combine(filePath, "argos-" + ProductName.ToLower());
                    if (!Directory.Exists(filePath))
                        Directory.CreateDirectory(filePath);

                    //check if sub directory
                    var parts = fileName.Split('.');
                    if (parts.Length > 2)
                    {
                        for (int i = 0; i < parts.Length - 2; i++)
                        {
                            filePath = Path.Combine(filePath, parts[i]);
                            if (!Directory.Exists(filePath))
                                Directory.CreateDirectory(filePath);

                            fileName = fileName.Replace(parts[i] + ".", "");
                        }
                    }

                    if (fileName == "build-custom.cmd")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = MobilePath;
                    }
                    if (fileName == "index-dev-custom.html")
                    {
                        fileName = fileName.Replace("custom", ProductName.ToLower());
                        filePath = Path.Combine(MobilePath, @"products\argos-saleslogix\");
                        if (!Directory.Exists(filePath))
                            Directory.CreateDirectory(filePath);
                    }

                    if (ProductCreateProgress != null)
                        ProductCreateProgress(this, new ProductCreateEventArgs { Count = count, CurrentFile = fileName, Total = total });

                    count++;

                    using (var writer = new StreamWriter(Path.Combine(filePath, fileName)))
                    {
                        writer.Write(fileContents);
                    }
                }
            }

            Program.Path = MobilePath;
            CreateIndexFile();

            if (ProductCreateComplete != null)
                ProductCreateComplete(this, new ProductCreateEventArgs { Count = count, CurrentFile = string.Empty, Total = total });
        }