Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoteCommandLine Execution Idea to make smarter #55

Open
danielmarbach opened this issue Dec 3, 2012 · 0 comments
Open

RemoteCommandLine Execution Idea to make smarter #55

danielmarbach opened this issue Dec 3, 2012 · 0 comments

Comments

@danielmarbach
Copy link
Contributor

Found a todo in the remote command line executor which indicates that currently all remote tasks are hard coded. A simple idea to make the console smarter would be the following:

public interface IRemoteTaskCreator
{
    Task Create(PhysicalServer server, string[] args);
}

[InvokedWith("create_queue")]
public class CreateLocalMsmqQueueTaskCreator : IRemoteTaskCreator
{
    public Task Create(PhysicalServer server, string[] args)
    {
        var queuename = args[1];
        var queueAddress = new QueueAddress(queuename);
        var transactional = false;
        if (args.Length > 2)
        {
            bool.TryParse(args[2], out transactional);
        }

        var task = new CreateLocalMsmqQueueTask(server, queueAddress, transactional);

        return task;
    }
}

public class InvokedWithAttribute : Attribute
{
    public string InvokeCommand { get; private set; }

    public InvokedWithAttribute(string invokeCommand)
    {
        InvokeCommand = invokeCommand;
    }
}

A simple reflection mechanism could cache all inheritors of IRemoteTaskCreator in a dictionary with <InvokeCommand , IRemoteTaskCreator>. The remote console then simple does:

var result = new DeploymentResult();
var creator = ClassWhichHasReflectionMagic.CreateRemoteTaskCreator(args[0]);
var task = creator.Create(_server, argsWithoutFirstEntry);
result = task.Execute();
return result;

Simple. Easy. Extendable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant