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); }
public virtual EntityCacheGeneric <string, DatabaseTableColumnWindows> GetForeignKeyColumns() { EntityCacheGeneric <string, DatabaseTableColumnWindows> result = new EntityCacheGeneric <string, DatabaseTableColumnWindows>(); _columns.Where(c => c.IsForeignKey).ToList().ForEach(c => result.Add(c.ColumnName, c)); return(result); }
public EntityCacheGeneric <string, List <SettingItem> > GetAllSettingItemsGroupedByCategories() { EntityCacheGeneric <string, List <SettingItem> > result = new EntityCacheGeneric <string, List <SettingItem> >(); foreach (var group in GetAllSettingItems().GroupBy(p => p.Category)) { result.Add(group.Key, group.OrderBy(p => p.CategorySequenceId).ToList()); } return(result); }
private static EntityCacheGeneric<string, ForeignKeyInfoWindows> GetForeignKeysFromSqlDataReader(SqlDataReader reader) { EntityCacheGeneric<string, ForeignKeyInfoWindows> result = new EntityCacheGeneric<string, ForeignKeyInfoWindows>(); while (reader.Read()) { ForeignKeyInfoWindows f = new ForeignKeyInfoWindows() { ChildTableName = reader[FOREIGN_KEY_TABLE_COLUMN_NAME].ToString(), ChildTableForeignKeyName = reader[FOREIGN_KEY_COLUMN_NAME].ToString(), ParentTableName = reader[PRIMARY_KEY_TABLE_COLUMN_NAME].ToString(), ParentTablePrimaryKeyName = reader[PRIMARY_KEY_COLUMN_NAME].ToString(), ConstraintName = reader[CONSTRAINT_NAME_COLUMN_NAME].ToString() }; result.Add(f.ChildTableForeignKeyName, f); } return result; }
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); }
public OrmTypeWindows CreateOrmType(string typeName, bool prefixWithAssemblyNamespace) { if (_ormTypes.Exists(typeName)) { throw new ArgumentException(string.Format( "{0} with {1} {2} already created on {3}.", typeof(OrmTypeWindows).FullName, EntityReaderGeneric <OrmTypeWindows> .GetPropertyName(p => p.TypeName, false), typeName, this.GetType().FullName)); } if (prefixWithAssemblyNamespace) { typeName = string.Format("{0}.{1}", _assemblyName, typeName); } TypeBuilder typeBuilder = _moduleBuilder.DefineType(typeName, TypeAttributes.Class | TypeAttributes.Public); ConstructorBuilder constructorBuilder = typeBuilder.DefineDefaultConstructor(MethodAttributes.Public); OrmTypeWindows result = new OrmTypeWindows(typeName, typeBuilder); _ormTypes.Add(result.TypeName, result); return(result); }
private void PopulateChildrenTables() { foreach (DatabaseTableWindows pkTable in _tables) { foreach (DatabaseTableWindows fkTable in _tables) //Find children tables i.e. tables that have foreign keys mapped this table's primary keys'. { EntityCacheGeneric <string, ForeignKeyInfoWindows> mappedForeignKeys = new EntityCacheGeneric <string, ForeignKeyInfoWindows>(); fkTable.GetForeignKeyColumns().Where(c => c.ParentTableName == pkTable.TableName).ToList().ForEach(fk => mappedForeignKeys.Add(fk.ColumnName, new ForeignKeyInfoWindows() { ChildTableName = fkTable.TableName, ChildTableForeignKeyName = fk.ColumnName, ParentTableName = fk.ParentTableName, ParentTablePrimaryKeyName = fk.ParentTablePrimaryKeyName, ConstraintName = fk.ConstraintName })); if (mappedForeignKeys.Count > 0) //If there are any foreign keys mapped to parent table's name. { pkTable.ChildrenTables.Add(fkTable.TableName, mappedForeignKeys); } } } }