davybrion / Agatha

Agatha Request-Response Service Layer for .NET
http://davybrion.github.com/Agatha/
Other
86 stars 39 forks source link

Polymorphic RequestHandler #33

Open michelgrootjans opened 10 years ago

michelgrootjans commented 10 years ago

Is it possible to have a more generic handler that can handle multiple types of requests. For example:

    public class ParentRequest : Request{ }
    public class ChildRequest  : ParentRequest { }

    public class TestRequestHandler : RequestHandler<ParentRequest, TestResponse>
    {
        public override Response Handle(ParentRequest request)
        {
            return new TestResponse();
        }
    }

This TestRequestHandler would then be able to handle a ChildRequest too.

You can view a full test here: https://gist.github.com/michelgrootjans/284aa97119a9daa4ea1a