private DatabaseAction?GetActionsAttribute(Type type) { if (ActionsAttributeCache.ContainsKey(type)) { return(ActionsAttributeCache[type]); } PropertyInfo dbSet = this.GetDbSetForType(type); if (dbSet != null) { AuditDatabaseActionsAttribute attribute = dbSet.GetCustomAttribute <AuditDatabaseActionsAttribute>(); if (attribute != null) { ActionsAttributeCache[type] = attribute.TrackActions; return(attribute.TrackActions); } } TypeInfo typeInfo = GetType().GetTypeInfo(); AuditDbContextAttribute dbContextAttribute = typeInfo.GetCustomAttribute <AuditDbContextAttribute>(); if (dbContextAttribute != null) { ActionsAttributeCache[type] = dbContextAttribute.TrackActions; return(dbContextAttribute.TrackActions); } else { ActionsAttributeCache[type] = null; return(null); } }
private void LoadConfig() { Type type = GetType(); AuditDbContextAttribute attribute = null; if (AuditAttributeCache.ContainsKey(type)) { attribute = AuditAttributeCache[type]; } else { attribute = type.GetTypeInfo().GetCustomAttribute <AuditDbContextAttribute>(); AuditAttributeCache[type] = attribute; } if (attribute != null) { Settings = attribute.Settings; } }