Example #1
0
        public EntityCacheGeneric <string, SettingItem> GetAllSettingItems(string name)
        {
            Type settingsType = this.GetType();
            List <SettingItem> settingItems = new List <SettingItem>();

            foreach (PropertyInfo p in settingsType.GetProperties())
            {
                object[] categoryAttributes = p.GetCustomAttributes(typeof(SettingInfoAttribute), true);
                if (categoryAttributes == null)
                {
                    continue;
                }
                foreach (SettingInfoAttribute c in categoryAttributes)
                {
                    SettingItem settingItem = new SettingItem(
                        c.Category,
                        p.Name,
                        EntityReader.GetPropertyValue(p.Name, this, false),
                        p.PropertyType,
                        c.AutoFormatDisplayName,
                        c.DisplayName,
                        c.Description,
                        c.CategorySequenceId,
                        c.PasswordChar,
                        null,
                        new SettingsCategoryInfo(this, c.Category));
                    settingItems.Add(settingItem);
                }
            }
            string entityCacheName = string.IsNullOrEmpty(name) ? DataShaper.ShapeCamelCaseString(this.GetType().Name) : name;
            EntityCacheGeneric <string, SettingItem> result = new EntityCacheGeneric <string, SettingItem>(entityCacheName);

            settingItems.OrderBy(p => p.Category).ToList().ForEach(p => result.Add(p.SettingName, p));
            return(result);
        }
Example #2
0
 public static void PopulateDataGridViewRowFromEntity(object entity, DataGridViewRow row, bool shapePropertyNames, Type entityType)
 {
     foreach (PropertyInfo p in entityType.GetProperties())
     {
         object propertyValue = EntityReader.GetPropertyValue(p.Name, entity, true);
         string propertyName  = shapePropertyNames ? DataShaperWindows.ShapeCamelCaseString(p.Name) : p.Name;
         row.Cells[propertyName].Value = propertyValue;
     }
 }
Example #3
0
        public EntityCacheGeneric <string, SettingItem> GetSettingsByCategory(SettingsCategoryInfo settingsCategoryInfo, SettingsControlWindows settingsControl)
        {
            string             categoryLower = settingsCategoryInfo.Category.Trim().ToLower();
            Type               settingsType  = this.GetType();
            List <SettingItem> settingItems  = new List <SettingItem>();

            foreach (PropertyInfo p in settingsType.GetProperties())
            {
                object[] categoryAttributes = p.GetCustomAttributes(typeof(SettingInfoAttribute), true);
                if (categoryAttributes == null)
                {
                    continue;
                }
                foreach (SettingInfoAttribute c in categoryAttributes)
                {
                    if (c.Category.Trim().ToLower() == categoryLower)
                    {
                        SettingItem settingItem = new SettingItem(
                            c.Category,
                            p.Name,
                            EntityReader.GetPropertyValue(p.Name, this, false),
                            p.PropertyType,
                            c.AutoFormatDisplayName,
                            c.DisplayName,
                            c.Description,
                            c.CategorySequenceId,
                            c.PasswordChar,
                            settingsControl,
                            settingsCategoryInfo);
                        settingItems.Add(settingItem);
                    }
                }
            }
            string entityCacheName = string.Format("{0} {1} Settings", DataShaperWindows.ShapeCamelCaseString(settingsType.Name).Replace("Settings", "").Trim(), settingsCategoryInfo.Category);
            EntityCacheGeneric <string, SettingItem> result = new EntityCacheGeneric <string, SettingItem>(entityCacheName);

            settingItems.OrderBy(p => p.CategorySequenceId).ToList().ForEach(p => result.Add(p.SettingName, p));
            return(result);
        }