i'm making a facade project / wrapper to a logging library. This wrapper is to be used in multiple projects, both existing and new ones.
The namespace is gonna be like Logger.System.Fatal, but since the existing projects used to consume another wrapper project, they used Logger.Fatal.
So with the new one, I want the same method to be able to be called from both places in the namespace.
But how do i go about doing this?
I would like to be able to have the same description in both places, but have the Logger.Fatal give a deprecated/obsolete warning.
I have thought of doing it like this:
public class Logger : LogHelper.System
{
[Obsolete("Logger.Trace is deprecated, use Logger.System.Fatal instead.")]
public static new void Fatal(string message)
{
//log the message
//somehow call the method that we are inheriting from
}
public class System : LogHelper.System
{
public static new void Fatal(string message)
{
//log the message
//somehow call the method that we are inheriting from
}
}
}
public class LogHelper
{
/// <summary>
/// Logs a message with the importance of Fatal
/// </summary>
/// <param name="message">The message to log</param>
public virtual void Fatal(string message)
{
//log the message
logger.Fatal(message);
}
}
But im unsure if this is the proper way to design it, or if it should just be called as normal methods referencing another? I'm looking for some best practice advice on how to design it :)
Aucun commentaire:
Enregistrer un commentaire