using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; namespace Cryville.Crtr.Config { public interface IPropertyMasterAdapter { string DefaultCategory { get; } IEnumerable GetProperties(); } public class DefaultPropertyMasterAdapter : IPropertyMasterAdapter { readonly object _target; public DefaultPropertyMasterAdapter(object target) { _target = target ?? throw new ArgumentNullException("target"); } public string DefaultCategory { get { return "miscellaneous"; } } public IEnumerable GetProperties() { return _target.GetType().GetProperties().Where(p => { var attrs = p.GetCustomAttributes(typeof(BrowsableAttribute), true); if (attrs.Length == 0) return true; else return ((BrowsableAttribute)attrs.Single()).Browsable; }).Select(p => new DefaultPropertyAdapter(_target, p)); } } }