Last active
October 5, 2015 07:56
-
-
Save fjeldstad/cb8da53be209a7a0775b to your computer and use it in GitHub Desktop.
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
public interface INode | |
{ | |
} | |
public interface IMessageToPublish | |
{ | |
object Message { get; } | |
TimeSpan? Delay { get; } | |
} | |
public class MessageToPublish | |
{ | |
public object Message { get; } | |
public TimeSpan? Delay { get; } | |
public MessageToPublish(object message, TimeSpan? delay = null) | |
{ | |
Message = message; | |
Delay = delay; | |
} | |
} | |
public abstract class Node<TState> : INode | |
{ | |
public interface IHandle<TMessage> | |
{ | |
Task<IMemory> AccessMemory(TMessage message); | |
ITransformResult Transform(TMessage message, TState state); | |
} | |
public interface IMemory | |
{ | |
TState State { get; } | |
Func<TState, Task> Overwrite { get; } | |
} | |
public interface ITransformResult | |
{ | |
TState NextState { get; } | |
IMessageToPublish[] MessagesToPublish { get; } | |
} | |
public class Memory : IMemory | |
{ | |
public TState State { get; } | |
public Func<TState, Task> Overwrite { get; } | |
public Memory(TState state, Func<TState, Task> overwrite) | |
{ | |
State = state; | |
Overwrite = overwrite; | |
} | |
} | |
public class TransformResult : ITransformResult | |
{ | |
public TState NextState { get; } | |
public IMessageToPublish[] MessagesToPublish { get; } | |
public TransformResult(TState nextState, params IMessageToPublish[] messagesToPublish) | |
{ | |
NextState = nextState; | |
MessagesToPublish = messagesToPublish ?? new IMessageToPublish[0]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get all node implementations in the currently executing assembly (for example) together with the types of input messages they expect: