Processor for handling generic commands I'm trying to implement business logic layer based on concepts of commands and command handlers. 

A command is a thing that contains input parameters for executing some action, and it knows what kind of output that action should produce. A command handler contains logic for actually executing an action: it accepts a command as a param, handles it in some way, and (if successful) produces an output object.

public interface ICommand&lt;TResultData&gt;
{ }

public interface ICommandHandler&lt;TCommand, TResultData&gt;
    where TCommand : ICommand&lt;TResultData&gt;
{    
    CommandResult&lt;TResultData&gt; Handle(TCommand command);
}

public static class CommandProcessor
{
    public static CommandResult&lt;TResultData&gt; Process&lt;TCommand, TResultData&gt;(TCommand command)
        where TCommand : ICommand&lt;TResultData&gt;
    {
        var handler = ServiceLocator.GetInstance&lt;ICommandHandler&lt;TCommand, TResultData&gt;&gt;();
        return handler.Handle(command);
    }
}
public class CommandResult&lt;TResultData&gt;
{
    public bool Success { get; set; }

    public string Error { get; set; }

    public TResultData Data { get; set; }
}


Example usage:

// CreateUserCommand &amp; handler implementations *very* simplified
public class CreateUserCommand : ICommand&lt;User&gt;
{
    public string Email { get; set; }
}

public class CreateUserCommandHandler : ICommandHandler&lt;CreateUserCommand, User&gt;
{
    private readonly IRepository repository;
    public CreateUserCommandHandler (IRepository repository)
    {
        this.repository = repository;
    }
    public CommandResult&lt;User&gt; Handle(CreateUserCommand command)
    {
        if(this.repository.Users.Any(u=&gt;u.Email == command.Email)
          return new CommandResult&lt;User&gt; { Success = false, Error = "Email already taken"};
        var user = new User {Email = command.Email};
        this.repository.Users.Add(user);
        return new CommandResult&lt;User&gt; { Success = true, Data = user};
    }
}

// command usage in application code
var command = new CreateUserCommand { Email = "some.email.com" };
CommandResult&lt;User&gt; result = CommandProcessor.Process(command);
if(result.Success)
{
    // at this point we know that result.Data is of type User, which is nice
    // so we can use this strictly-typed result data in any way
    User createdUser = result.Data;
    Console.Writeline("Created user with Id = " + createdUser.Id);
}
else
{
    Console.Writeline("Error creating user: " + result.Error);
}


Everything works pretty nice, as you can see in the usage example, but one thing that bothers me is the empty interface ICommand. Is it a bad thing here? Can the code be refactored in some way to make it better?
Your marker interface has no added value. In fact, it's an anti-pattern because you provide a generic type parameter on an interface ICommand, only to enforce it on another interface ICommandResult.


public interface ICommand&lt;TResultData&gt;
{ }

public interface ICommandHandler&lt;TCommand, TResultData&gt;
    where TCommand : ICommand&lt;TResultData&gt;
{    
    CommandResult&lt;TResultData&gt; Handle(TCommand command);
}



Since specific commands have nothing in common, I would not create an interface for commands. Also, TResultData has nothing to do with a command, and everything with the command result. 

The handler could be rewritten as follows:

public interface ICommandHandler&lt;TCommand, TResultData&gt;
{    
    CommandResult&lt;TResultData&gt; Handle(TCommand command);
}