Exemplo n.º 1
0
        private static SortedDictionary <string, EnvironmentSettingsGroup> LoadConfiguration()
        {
            var section  = (EnvironmentSettingsSection)ConfigurationManager.GetSection(SectionName);
            var settings = new SortedDictionary <string, EnvironmentSettingsGroup>();

            if (section != null)
            {
                EnvironmentSettingsGroup defaultElement = null;

                foreach (EnvironmentSettingsGroup element in section.EnvironmentSettings)
                {
                    if (element.Key.ToUpper() == DefaultKeyName)
                    {
                        defaultElement = element;
                        break;
                    }
                }

                foreach (EnvironmentSettingsGroup element in section.EnvironmentSettings)
                {
                    if (string.IsNullOrEmpty(element.ConnectionString))
                    {
                        element.ConnectionString = defaultElement.ConnectionString;
                    }

                    if (string.IsNullOrEmpty(element.RetailerCode))
                    {
                        element.RetailerCode = defaultElement.RetailerCode;
                    }

                    settings.Add(element.Key, element);
                }
            }
            return(settings);
        }
 public void Remove(EnvironmentSettingsGroup details)
 {
     if (BaseIndexOf(details) >= 0)
     {
         BaseRemove(details.Key);
     }
 }
        public EnvironmentSettingsGroupCollection()
        {
            EnvironmentSettingsGroup details = (EnvironmentSettingsGroup)CreateNewElement();

            if (details.Key != "")
            {
                Add(details);
            }
        }
 public void Add(EnvironmentSettingsGroup details)
 {
     BaseAdd(details);
 }
 public int IndexOf(EnvironmentSettingsGroup details)
 {
     return(BaseIndexOf(details));
 }