Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

Generic interface inheritence (type inference?)

$
0
0
Hi

I am trying to implement a CQRS project template similar to this C# example

Their (C#) interface for command handler is:-
Code:

public interface ICommandHandler where T : ICommand
{
    void Handle(T command);
}

and I have this as follows in VB.Net :-
Code:

''' <summary>
''' Interface for a class that handles a given command
''' </summary>
''' <typeparam name="TCommand">
''' The command definition (including any parameters) to execute
''' </typeparam>
''' <remarks>
''' The linkage between command and command handler is performed by Unity as the IoC container
''' </remarks>
Public Interface ICommandHandler(Of In TCommand As ICommandDefinition)

    ''' <summary>
    ''' Perform the actions underlying performing this command
    ''' </summary>
    ''' <param name="command">
    ''' The comand (with any parameters) to execute
    ''' </param>
    ''' <remarks>
    ''' Each command will have a single implementing class command handler
    ''' </remarks>
    Sub Handle(ByVal command As TCommand)

End Interface

Which works fine for a hard-wired class that maps to the command handler type of process.
e.g.
Code:

    Public Class PingCommandHandler
        Implements ICommandHandler(Of Definitions.PingCommandDefinition)

        Public Sub Handle(command As Definitions.PingCommandDefinition) Implements ICommandHandler(Of Definitions.PingCommandDefinition).Handle

        End Sub

    End Class

However I want to hook up the command and command handler using "unity"....

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>