public static string GetCurrentValue(this PropertyEntry propertyEntry) { var entityType = propertyEntry.EntityEntry.Metadata.ClrType; var propertyName = propertyEntry.Metadata.Name; if (HistoryConfiguration.IsOverridden(entityType, propertyName, out object overrideValue)) { return(overrideValue?.ToString().TruncateWithPostfix(EntityPropertyChange.MaxValueLength)); } if (HistoryConfiguration.IsFormated(entityType, propertyName, out Func <object, object> formatedFunc)) { return(formatedFunc.Invoke(propertyEntry.CurrentValue)?.ToString().TruncateWithPostfix(EntityPropertyChange.MaxValueLength)); } return(propertyEntry.CurrentValue?.ToString().TruncateWithPostfix(EntityPropertyChange.MaxValueLength)); }
public void Start(Action<HistoryConfiguration> configurator) { _historyKeys = _assemblySource.SelectMany(assembly => FindKeys(assembly)).ToList(); _assemblySource.AssemblyAdded += assembly => FindKeys(assembly).Apply(x => _historyKeys.Add(x)); _config = new HistoryConfiguration { DeterminePresenter = value =>{ var key = _historyKeys.FirstOrDefault(x => x.Value == value); return key != null ? key.GetInstance() : null; } }; configurator(_config); _config.Host.PropertyChanged += Host_PropertyChanged; _stateManager.AfterStateLoad += OnAfterStateLoad; _stateManager.Initialize(_config.StateName); }
protected virtual bool ShouldSavePropertyHistory(PropertyEntry propertyEntry, bool defaultValue) { if (propertyEntry.Metadata.IsPrimaryKey()) { return(false); } var entityType = propertyEntry.EntityEntry.Entity.GetType(); var propertyName = propertyEntry.Metadata.Name; if (!HistoryConfiguration.IsIncluded(entityType, propertyName)) { return(false); } ; if (propertyEntry.IsModified) { return(true); } return(defaultValue); }
public virtual IConfigurator ForEntity <TEntity>(Action <IEntityConfiguration <TEntity> > config) { HistoryConfiguration.SetEntityConfig(config); return(this); }
public virtual IConfigurator AllInclude(Type entityType) { HistoryConfiguration.SetEntityConfig(entityType); return(this); }
public virtual IConfigurator AllInclude <TEntity>() { HistoryConfiguration.SetEntityConfig(typeof(TEntity)); return(this); }
public HistoryWriter(HistoryConfiguration configuration, IHistoryReader historyReader, JsonSerializer serializer) { _configuration = configuration; _historyReader = historyReader; _serializer = serializer; }
public HistoryReader(HistoryConfiguration configuration, JsonSerializer serializer) { _configuration = configuration; _serializer = serializer; }