using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Linq; namespace Kreta.Core.FeatureToggle.Configuration { public class SimpleFeatureConfiguration : ConfigurationElement { [ConfigurationProperty(nameof(Name), IsKey = true, IsRequired = true)] public string Name => base[nameof(Name)].ToString(); [ConfigurationProperty(nameof(IsEnabled), IsKey = false, IsRequired = true)] public bool IsEnabled => bool.Parse(base[nameof(IsEnabled)].ToString()); [ConfigurationProperty(nameof(InstituteIds), IsKey = false, IsRequired = false)] [TypeConverter(typeof(CommaDelimitedStringCollectionConverter))] public IEnumerable InstituteIds { get { var instituteIds = ((CommaDelimitedStringCollection)base[nameof(InstituteIds)]); return (instituteIds != null) ? instituteIds.OfType() : new List(); } } [ConfigurationProperty(nameof(Environments), IsKey = false, IsRequired = false)] [TypeConverter(typeof(CommaDelimitedStringCollectionConverter))] public IEnumerable Environments { get { var environments = ((CommaDelimitedStringCollection)base[nameof(Environments)]); return (environments != null) ? environments.OfType() : new List(); } } } }