Created
February 13, 2021 00:43
-
-
Save mttchpmn/408ca3dfda2eb5990dbb298bc7f3f827 to your computer and use it in GitHub Desktop.
C# Workflow Engine Class
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
using System; | |
using System.Collections.Generic; | |
namespace Sandbox | |
{ | |
public interface IActivity | |
{ | |
void Execute(); | |
} | |
public class VideoUpload : IActivity | |
{ | |
public void Execute() | |
{ | |
Console.WriteLine("Uploading video..."); | |
} | |
} | |
public class NotifiyWebService : IActivity | |
{ | |
public void Execute() | |
{ | |
Console.WriteLine("Notifiying web service..."); | |
} | |
} | |
public class SendEmail : IActivity | |
{ | |
public void Execute() | |
{ | |
Console.WriteLine("Sending email..."); | |
} | |
} | |
public class UpdateDatabase : IActivity | |
{ | |
public void Execute() | |
{ | |
Console.WriteLine("Updating database..."); | |
} | |
} | |
public class WorkflowEngine | |
{ | |
private readonly IList<IActivity> _activities; | |
public WorkflowEngine(IList<IActivity> activities) | |
{ | |
_activities = activities; | |
} | |
public void Run() | |
{ | |
foreach (var activity in _activities) | |
{ | |
activity.Execute(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment