Exemplo n.º 1
0
        /// <summary>
        /// Encrypts the appsetting values specified by the appsetting with the key EncryptAppSettings.
        /// Encrypts the connection strings specified by the appsetting with the key EncryptConnStrings.
        /// Values are expected to be comma and/or semi colon separated lists of keys or names.
        /// Saves the specified values to and injects values from Profiguration.Default
        /// </summary>
        public static void Initialize()
        {
            string appKeysString        = DefaultConfiguration.GetAppSetting(EncryptAppSettingsKey);
            string connStringKeysString = DefaultConfiguration.GetAppSetting(EncryptConnStringsKey);

            Profiguration prof = Profiguration.Default;

            if (!string.IsNullOrEmpty(appKeysString))
            {
                string[] appSettingKeys = appKeysString.DelimitSplit(",", ";");
                foreach (string key in appSettingKeys)
                {
                    prof.CopyAppSetting(key);
                }
            }

            if (!string.IsNullOrEmpty(connStringKeysString))
            {
                string[] connStringNames = connStringKeysString.DelimitSplit(",", ";");
                foreach (string name in connStringNames)
                {
                    prof.CopyConnectionString(name);
                }
            }

            prof.Save();
            prof.Inject();
        }
Exemplo n.º 2
0
 protected internal Profiguration Save(string name, Profiguration toSave)
 {
     lock (_writeLock)
     {
         string path = Path.Combine(RootDirectory.FullName, name);
         toSave.Save(path);
         NamedProfigurations[name] = toSave;
         return(toSave);
     }
 }
Exemplo n.º 3
0
 protected void Load()
 {
     RootDirectory.Refresh();
     if (RootDirectory.Exists)
     {
         NamedProfigurations = new Dictionary <string, Profiguration>();
         FileInfo[] files = RootDirectory.GetFiles();
         files.Each(file =>
         {
             if (file.HasNoExtension())
             {
                 NamedProfigurations[file.Name] = Profiguration.Load(file.FullName);
             }
         });
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Get the profiguration of the specified name, creating it
        /// if necessary.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected internal Profiguration Get(string name)
        {
            lock (_writeLock)
            {
                Profiguration result = new Profiguration();
                string        path   = Path.Combine(RootDirectory.FullName, name);
                if (File.Exists(path))
                {
                    result = Profiguration.Load(path);
                }
                else
                {
                    result.Save(path);
                }

                NamedProfigurations[name] = result;
                return(result);
            }
        }