Tech Off Post

Single Post Permalink

View Thread: Can I overload a Ctor on a Generic Type?
  • User profile image
    Curt Nichols

    phreaks said:
    stevo_ said:
    Wow, thanks for all the great replies.

    That's pretty cool Tommy but how does that buy me a ctor that let's me over-ride the filepath string?

    I think that I have bigger design issues...

    It doesn't seem right to have  a FielPath field, because some of the concrete classes won't implment them (such as EmailLogger, DataBaseLogger).

    But I want this to be flexible so that I can chain all the loggers together if I want to log to many different types (DB, Email, Xml, etc)

    Any good ideas?

    Phreaks, it might be better to decompose this into two types, LogEngine and LogWriter, where the first is a concrete type that implements the publicly visible operations of writing a log entry and the second is  an interface  or abstract type, from which you can specialize types for file, email, database, etc. If needed, create a LogEngineFactory that creates a concrete LogWriter and hands it to a new LogEngine instance according to configuration.


    I don't see the value of having this be generic, you can lose that part without losing any value or functionality.