Skip to main content

Posts

Showing posts with the label digging

Digging through SignalR - Command Line Arguments

SignalR contains a console application that can be used to make stress tests. The solution that was used to parse the command parameters was ‘cmdline – Command Line Parser’. This is a pretty nice library that can be installed using NuGet. This command line parses works perfectly, this is why the last time when it was updated in in September 2012. Beside this solution, you can find another solution on Codeplex and github called very similar “Command Line Parser Library”. Both solutions are great and resolve the same problem in a very similar way. First time when I saw this two solutions I could swear that are the same solution (from the available API). I saw a lot of projects, where people started to implement their own arguments parsers, even if we have plenty of them on the marker. It is not so important what command line parser you use it, as long you use it and don’t rewrite it again and again. In general, the use cases that we need to support are pretty simple and are covered by ...

Digging through SignalR - Dependency Resolver

I’m continuing the series of post related to SignalR with dependency injection. When having a complicated business you can start to group different functionalities in classes. Because of this you can end up very easily with classes that accept in constructor 4-5 or even 10 parameters. public abstract class PersistentConnection { public PersistentConnection( IMessageBus messageBus, IJsonSerializer jsonSerializer, ITraceManager traceManager, IPerformanceCounterManager performanceCounterManager, IAckHandler ackHandler, IProtectedData protectedData, IConfigurationManager configurationManager, ITransportManager transportManager, IServerCommandHandler serverCommandHandler, HostContext hostContext) { } ... } Of course you have a decoupled solution that can be tested very easily, but in the same time you have a fat constructor. People would say: “Well, we have dependency injector, the resolver will handle the constructo...

Digging through SignalR - Commands

Looking over source code of SignalR. I found some interesting class and ways to implement different behaviors. In the next series of post I will share with you what I found interesting. Before starting, you should know that SignalR is an open source project that can be accessed using GitHub . In today post we will talk about command pattern. This patterns over the ability to define a “macro”/command that can be executed without knowing the caller. Commands can be handle in different ways, from create a queue of them to combining or offering support for redo/undo. In SignalR library I found an implementation of command pattern that caught my attention. internal interface ICommand { string DisplayName { get; } string Help { get; } string[] Names { get; } void Execute(string[] args); } internal abstract class Command : ICommand { public Command(Action<string> info, Action<string> success, Action<string> warning, Action<string> error) { ...