Example #1
0
 static string[] GetRequestedProfiles(IAzureConfigurationSettings azureSettings)
 {
     string requestedProfileSetting;
     if (azureSettings.TryGetSetting(ProfileSetting, out requestedProfileSetting))
     {
         var requestedProfiles = requestedProfileSetting.Split(' ');
         requestedProfiles = AddProfilesFromConfiguration(requestedProfiles);
         return requestedProfiles;
     }
     return new string[0];
 }
Example #2
0
        static string[] GetRequestedProfiles(IAzureConfigurationSettings azureSettings)
        {
            string requestedProfileSetting;

            if (azureSettings.TryGetSetting(ProfileSetting, out requestedProfileSetting))
            {
                var requestedProfiles = requestedProfileSetting.Split(' ');
                requestedProfiles = AddProfilesFromConfiguration(requestedProfiles);
                return(requestedProfiles);
            }
            return(new string[0]);
        }
        T IConfigurationSource.GetConfiguration <T>()
        {
            var sectionName = typeof(T).Name;

            if (cache && ConfigurationCache.ContainsKey(sectionName))
            {
                return((T)ConfigurationCache[sectionName]);
            }

            var section = GetConfigurationHandler()
                          .GetSection(sectionName) as T;

            foreach (var property in typeof(T).GetProperties().Where(x => x.DeclaringType == typeof(T)))
            {
                var adjustedPrefix = !string.IsNullOrEmpty(ConfigurationPrefix) ? ConfigurationPrefix + "." : string.Empty;

                string setting;

                if (!azureConfigurationSettings.TryGetSetting(adjustedPrefix + sectionName + "." + property.Name, out setting))
                {
                    continue;
                }
                if (section == null)
                {
                    section = new T();
                }

                property.SetValue(section, Convert.ChangeType(setting, property.PropertyType), null);
            }

            if (cache)
            {
                ConfigurationCache[sectionName] = section;
            }

            return(section);
        }