This project is read-only.


A component can be a user interface control or any other .NET object. The component works using the following pattern:
  • receive request message
  • execute command
  • post response message
According to incoming messages the component can update its state. The component can access external services, global application singletons and ask states of other components.

var now = Env.Components.First<ITimeProvider>().Now;
Every component is examined during adding it to the ComponentContainer.

Env.Components.Add(new LoginComponent());
Each method marked with MessageSubscriberAttribute is added to the invocation list of the according message channel.
You should avoid sophisticated logic in a component. Advanced algorithms should be located in Commands and helper classes which are easy testable with unit tests.


public class LoginComponent : IMyComponent
    private CommandAsyncExecutor<LoginCommand> _loginCommandAsyncExecutor;

    public LoginComponent()
        _loginCommandAsyncExecutor=new CommandAsyncExecutor<LoginCommand>();
        _loginCommandAsyncExecutor.ExecuteCompleted += on_loginCommandAsyncExecutor_ExecuteCompleted;

    private void handleLoginRequestMessage(LoginRequestMessage m)
        // Each command has Argument and Result properties
        var arg = new LoginCommandArgument(m.Name, Env.Components.TimeProvider);
        var cmd = new LoginCommand(arg);


    private void on_loginCommandAsyncExecutor_ExecuteCompleted(object sender, CommandEventArgs<LoginCommand> e)
        var mes = new LoginResponseMessage(e.Command.Error);
        if (!mes.HasError)
            // no error
            mes.Greeting = e.Command.Result.Greeting;



Each component should end with the suffix Component.

Last edited Jan 13, 2013 at 8:43 AM by polo, version 2


No comments yet.