You have to set the value on the appropriate entry in the currentState array, you can't set it on the property itself. Setting the value on the array item will also cause it to be set on the property. Here's a sample from my AuditInterceptor:
Code:
private void SetRevised(object[] currentState, string[] propertyNames)
{
int revisedByIndex = Array.FindIndex(propertyNames, s => s.Equals("RevisedBy"));
int revisedDateIndex = Array.FindIndex(propertyNames, s => s.Equals("RevisedDate"));
currentState[revisedByIndex] = UserName;
currentState[revisedDateIndex] = DateTime.Now;
}
// Update
public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, NHibernate.Type.IType[] types)
{
if (entity is IAuditable)
{
log.DebugFormat("OnFlushDirty setting revised fields. {0} {1}", entity.GetType().Name, id);
SetRevised(currentState, propertyNames);
return true;
}
log.DebugFormat("OnFlushDirty called on entity that does not implement IAuditable. {0} {1}", entity.GetType().Name, id);
return false;
}