Skip to content

Instantly share code, notes, and snippets.

@mttchpmn
Created February 13, 2021 00:43
Show Gist options
  • Save mttchpmn/408ca3dfda2eb5990dbb298bc7f3f827 to your computer and use it in GitHub Desktop.
Save mttchpmn/408ca3dfda2eb5990dbb298bc7f3f827 to your computer and use it in GitHub Desktop.
C# Workflow Engine Class
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