Griffin Framework is an business application library with features that .NET itself is missing.





Examples

 

A data mapping layer. Can be used only for mapping or to take care of CRUD operations too. The mapping layer works as extension methods on the ADO.NET API, i.e. you write SQL queries and the layer takes care of the rest.

Works on Connection objects, Command objects and our own unit of work contract. The api supports both synchronous and asynchronous methods.

// API
var users = connection.ToList<User>("firstName LIKE @1 AND lastName LIKE @2", firstName, lastName);
uow.Insert(user);
Mapping class
public class UserMapping : CrudEntityMapper<User>
{
    public override void Configure(IDictionary<string, PropertyMapping> mappings)
    {
        base.Configure(mappings);

        mappings["YourCustomKey"].IsPrimaryKey = true;
    }
}

 

A Command/Query seperation layer wich also supports events and request/reply type of messages.

Start small with our simple setup or our Inversion Of Control setup, later scale your appliction using our networking implementation.

Allows you to build micro services easily.

// requst/reply example
public class Login : Request<LoginReply>
{
    public Login(string userName, string password)
    {
        Password = password;
        UserName = userName;
    }
 
    public string UserName { get; private set; }
    public string Password { get; private set; }
}

// the reply  
public class LoginReply
{
    public bool Success { get; set; }
    public Account Account { get; set; }
}

// Call that receives the request and generates the reply
public class LoginHandler : IRequestHandler<Login, LoginReply>
{
    public Task<LoginReply> ExecuteAsync(Login request)
    {
        //do something
        // exceptions will be handled by the library
                            
        return new LoginReply(blabla);
    }
}

// Executed by the client
// the requestBus implementation depends on your setup
// * simple (works of the box(
// * ioc (requires an ioc container)
// * Net (requires a server i.e. nuget package griffinframework.cqs.server)
var reply = await requestBus.ExecuteAsync(new Login("jonas", "arne"));
if (reply.Success)
{
    Console.WriteLine("Authenticated as " + reply.Account.UserName);
}

 

The networking library is fully asynchronous and it's easy to use existing protocols or create your own.

Here is a sample using our own MicroMsg protocol.

public class Server
{
    private readonly ChannelTcpListener _server;
 
    public Server()
    {
        _server = new ChannelTcpListener();
        _server.MessageReceived += OnMessage;
        _server.ClientConnected += OnClientConnected;
        _server.ClientDisconnected += OnClientDisconnected;
    }
 
    public int LocalPort
    {
        get { return _server.LocalPort; }
    }
 
    public void Start()
    {
        _server.Start(IPAddress.Any, 0);
    }
 
    private void OnClientConnected(object sender, ClientConnectedEventArgs e)
    {
        Console.WriteLine("Got connection from client with ip " + e.channel.RemoteEndPoint);
    }
 
    private void OnClientDisconnected(object sender, ClientDisconnectedEventArgs e)
    {
        Console.WriteLine("Disconnected: " + e.Channel.RemoteEndpoint);
    }
 
    private void OnMessage(ITcpChannel channel, object message)
    {
        Console.WriteLine("Server received: " + message);
        channel.Send(Encoding.ASCII.GetBytes("Hello  world"));
    }
}