public EventMessage(EventType kind, IIdentityKey data) { if (data == null) { throw new ArgumentNullException("data"); } Id = Guid.NewGuid().ToString(); Kind = kind; ReferenceId = data.Id; Data = data; OccurredOn = DateTime.UtcNow; }
protected IDictionary <string, object> GetParametersFromEntity(IIdentityKey <TKey> key, params string[] excluded) { var result = new Dictionary <string, object>(); var properties = key.GetType().GetProperties().Where(x => x.CanRead && !excluded.Contains(x.Name)); foreach (var property in properties) { var propKey = property.Name; var propValue = property.GetValue(key, null); if (typeof(IIdentityKey <TKey>).IsAssignableFrom(property.PropertyType)) { propKey = property.PropertyType.Name + "Id"; var asIkey = propValue as IIdentityKey <TKey>; propValue = (asIkey != null) ? (object)asIkey.Id : null; } result.Add(propKey, propValue); } return(result); }