Example #1
0
        public void Save(List <ApprovedDomain> domains)
        {
            string contents = JsonConvert.SerializeObject(domains, Formatting.Indented);
            string path     = PathMapper.MapPath(Path + this.FileName);

            if (path == null)
            {
                return;
            }

            File.WriteAllText(path, contents, new UTF8Encoding(false));
        }
        public static string GetConnectionString()
        {
            string path = PathMapper.MapPath("/Resources/Configs/RedisConfig.json");

            if (File.Exists(path))
            {
                string contents = File.ReadAllText(path, Encoding.UTF8);
                var    config   = JsonConvert.DeserializeObject <RedisConfig>(contents);

                return(config.ConfigString);
            }

            return(string.Empty);
        }
Example #3
0
        static AppResolver()
        {
            string root  = PathMapper.MapPath("~/");
            var    files = Directory.GetFiles(root, "AppInfo.json", SearchOption.AllDirectories).ToList();

            var installables = new List <Installable>();

            foreach (string file in files)
            {
                string contents    = File.ReadAllText(file, Encoding.UTF8);
                var    installable = JsonConvert.DeserializeObject <Installable>(contents);
                installable.DirectoryPath = Path.GetDirectoryName(file);
                installables.Add(installable);
            }

            Installables = installables;
        }
Example #4
0
        /// <summary>
        ///     Gets the configuration value of the requested key.
        /// </summary>
        /// <param name="configFileName">The name of the configuration file.</param>
        /// <param name="key">The configuration key to find.</param>
        /// <returns>Returns the configuration value of the requested key.</returns>
        public static string GetConfigurationValue(string configFileName, string key)
        {
            Log.Verbose($"Getting configuration key \"{key}\" on config file \"{configFileName}\".");

            if (configFileName == null)
            {
                Log.Verbose($"Empty string returned for the key \"{key}\" because no config file name was provided.");
                return(string.Empty);
            }

            string fileName = System.Configuration.ConfigurationManager.AppSettings[configFileName];

            Log.Verbose($"Configuration file for \"{configFileName}\" is {fileName}.");

            string path = PathMapper.MapPath(fileName);

            return(ReadConfigurationValue(path, key));
        }
Example #5
0
        public List <ApprovedDomain> Get()
        {
            var domains = new List <ApprovedDomain>();

            string path = PathMapper.MapPath(Path + this.FileName);

            if (path == null)
            {
                return(domains);
            }

            if (!File.Exists(path))
            {
                return(domains);
            }

            string contents = File.ReadAllText(path, Encoding.UTF8);

            domains = JsonConvert.DeserializeObject <List <ApprovedDomain> >(contents);

            return(domains ?? new List <ApprovedDomain>());
        }
Example #6
0
        public static IEnumerable <Installable> GetInstallables(string tenant)
        {
            string root         = PathMapper.MapPath("~/");
            var    installables = new List <Installable>();

            if (root == null)
            {
                return(installables);
            }

            var apps = AppResolver.Installables;

            foreach (var app in apps)
            {
                app.SetDependencies();

                if (app.AutoInstall)
                {
                    installables.Add(app);
                }
            }

            return(installables);
        }