Created
March 30, 2017 19:38
-
-
Save justinAurand/3879cbb48bd26aeef9941cce969d6589 to your computer and use it in GitHub Desktop.
Getting a workflow runner from a service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace WorkflowActions | |
{ | |
using System; | |
internal class Program | |
{ | |
private static void Main() | |
{ | |
const string workflowName = "Ftp"; | |
var workflowService = new WorkflowService(); | |
var workflow = workflowService.Get(workflowName); | |
workflow?.Run(); | |
} | |
} | |
public interface IRunnableWorkflow | |
{ | |
void Run(); | |
} | |
public interface IWorkflowService | |
{ | |
IRunnableWorkflow Get(string name); | |
} | |
public class Ftp : IRunnableWorkflow | |
{ | |
public void Run() | |
{ | |
Console.WriteLine("************************************************Inside FTP"); | |
Console.ReadKey(); | |
} | |
} | |
public class WorkflowService : IWorkflowService | |
{ | |
public IRunnableWorkflow Get(string name) | |
{ | |
var currentNameSpace = typeof (Program).Namespace; | |
var type = Type.GetType(currentNameSpace + "." + name); | |
if (type == null) | |
return null; | |
return (IRunnableWorkflow) Activator.CreateInstance(type); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment