What about making the Register method generic?
public class Mediator
{
private Dictionary<Messages, Action<object>> registeredCallback =
new Dictionary<Messages, Action<object>>();
public void Register<TParam>(Messages message, Action<TParam> callback)
{
registeredCallback[message] = p => callback((TParam)p);
}
public void Notify(Messages message, object parameter)
{
callback(parameter);
}
}
The typecasting is done inside the Register method, making it invisible to any class using it.
You can also change signature of the GreetUser method so that it takes a User instead of ana objectstring as a parameter. By doing so you can call Register like this:
mediator.Register<User>(Messages.UserCreated, GreetUser);