//public SqlIdProvider() //{ // this.SecurityTypes = new SecurityTypes(); // this.ContentSources = new ContentSources(); // this.ContentTypes = new ContentTypes(); //} public void Init(ISqlIdDataService source) { this.SecurityTypes = new SecurityTypes(source); this.ContentSources = new ContentSources(source); this.ContentTypes = new ContentTypes(source); this.CoreContent = new CoreContent(source); }
public void PopulateSqlIds(ISqlIdDataService source) { IEnumerable <T> idTable = source.GetIdTable <T>(this.TableName); PropertyInfo[] properties = this.GetType().GetProperties(); foreach (PropertyInfo property in properties) { object attr = property.GetCustomAttributes(typeof(SqlIdAttribute), true).FirstOrDefault(); if (attr != null) { string keyName = null; var sqlId = (SqlIdAttribute)attr; if (!string.IsNullOrEmpty(sqlId.Name)) { keyName = sqlId.Name; } else { keyName = property.Name; } if (!string.IsNullOrEmpty(keyName)) { int id = -1; foreach (T row in idTable) { PropertyInfo[] rowProperties = row.GetType().GetProperties(); PropertyInfo keyColumn = rowProperties.FirstOrDefault(prop => prop.Name.ToUpper() == this.KeyColumnName.ToUpper()); if (keyColumn != null && keyColumn.GetValue(row, null).ToString().ToUpper() == keyName.ToUpper()) { PropertyInfo idColumn = rowProperties.FirstOrDefault(prop => prop.Name.ToUpper() == this.ValueColumnName.ToUpper()); if (idColumn != null) { id = (int)idColumn.GetValue(row, null); } break; } } } } } }
public ContentTypes(ISqlIdDataService source) : this() { base.PopulateSqlIds(source); }
public SecurityTypes(ISqlIdDataService source) : this() { base.PopulateSqlIds(source); }
public SqlIdTableBase(string tableName, ISqlIdDataService source) { this.TableName = tableName; this.PopulateSqlIds(source); }