private void SetTableMeta() { // We get the current assembly through the current class var currentAssembly = Assembly.GetExecutingAssembly(); // we filter the defined classes according to the interfaces they implement var stuff = currentAssembly.DefinedTypes.Where(type => type.ImplementedInterfaces.Any(inter => inter == typeof(IOrmLiteTableMetaData))).ToList(); foreach (Type type in stuff) { IOrmLiteTableMetaData temp = (IOrmLiteTableMetaData)Activator.CreateInstance(type); temp.SetTableMetaData(_dbFactory); } OnLogEvent?.Invoke(this, $"{stuff.Count} table meta data initialized"); }
private void SetTableMeta2() { // We get the current assembly through the current class var currentAssembly = Assembly.GetExecutingAssembly(); // we filter the defined classes according to the interfaces they implement var stuff = currentAssembly.DefinedTypes.Where(type => type.IsSubclassOf(typeof(MetaDataBaseClass))).ToList(); foreach (Type type in stuff) { IOrmLiteTableMetaData temp = (IOrmLiteTableMetaData)Activator.CreateInstance(type); temp.SetTableMetaData(_dbFactory); } stuff = currentAssembly.DefinedTypes.Where(type => type.IsSubclassOf(typeof(CoreObject))).ToList(); foreach (Type type in stuff) { type.AddAttributes(new AliasAttribute("TEST_" + type.Name)); } OnLogEvent?.Invoke(this, $"{stuff.Count} table meta data initialized"); }