Exemplo n.º 1
0
        private static IDictionary <string, TemplateSetting> LoadFromDirectory(string rootDirPath)
        {
            IDictionary <string, TemplateSetting> dict;
            DirectoryInfo dir = new DirectoryInfo(rootDirPath);

            DirectoryInfo[] dirs = dir.GetDirectories();
            dict = new Dictionary <string, TemplateSetting>(dirs.Length);
            if (!dir.Exists)
            {
                return(dict);
            }
            foreach (DirectoryInfo d in dirs)
            {
                if ((d.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    String tplConfigFile = String.Format("{0}{1}/tpl.conf", rootDirPath, d.Name);
                    if (!File.Exists(tplConfigFile))
                    {
                        SettingFile sf = new SettingFile(tplConfigFile);
                        sf.Set("name", d.Name);
                        sf.Flush();
                    }
                    TemplateSetting ts = new TemplateSetting(d.Name, tplConfigFile);
                    ts.CfgEnabledMobiPage = Directory.Exists(String.Format("{0}{1}/_mobile_", rootDirPath, d.Name));
                    dict.Add(d.Name, ts);
                }
            }
            return(dict);
        }
Exemplo n.º 2
0
        private static IDictionary <string, TemplateSetting> LoadFromDirectory(string rootDirPath)
        {
            var dir  = new DirectoryInfo(rootDirPath);
            var dirs = dir.GetDirectories();
            IDictionary <string, TemplateSetting> dict = new Dictionary <string, TemplateSetting>(dirs.Length);

            if (!dir.Exists)
            {
                return(dict);
            }
            foreach (var d in dirs)
            {
                if ((d.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    var tplConfigFile = $"{rootDirPath}{d.Name}/tpl.conf";
                    if (!File.Exists(tplConfigFile))
                    {
                        var sf = new SettingFile(tplConfigFile);
                        sf.Set("name", d.Name);
                        sf.Flush();
                    }

                    var ts = new TemplateSetting(d.Name, tplConfigFile)
                    {
                        CfgEnabledMobiPage = Directory.Exists($"{rootDirPath}{d.Name}/_mobile_")
                    };
                    dict.Add(d.Name, ts);
                }
            }

            return(dict);
        }