public void Initialize()
        {
            if (isInitialized)
            {
                return;
            }

            //Dependencies Initialization
            //In XVS this is done automatically via MEF, here we need to do it manually
            var fingerprintRetriever = new FingerprintRetriever();
            var settings             = new InMemoryRemoteServerSettings();
            var dialogProvider       = new TestDialogProvider();
            var progress             = new Progress <string>(x => Console.WriteLine(x));
            var errorsManager        = new TestErrorsManager();
            var asyncManager         = new AsyncManager();

            EventStream = new EventStream();

            //The Server Source represents a type of server that you want to support connection
            //If you want to connect against a Linux Server, a Mac Server, a Windows Server, an IoT Server, etc,
            //you would need to define a Server Source for each of those types
            var serverSource = new TestServerSource(fingerprintRetriever,
                                                    settings,
                                                    dialogProvider,
                                                    progress,
                                                    errorsManager,
                                                    asyncManager,
                                                    EventStream);

            //Dependencies initialization for the command handlers
            //In XVS this is done automatically via MEF, here we need to do it manually
            ServerSourceManager = new RemoteServerSourceManager();

            var connectionManager = new TestServerConnectionManager(ServerSourceManager, asyncManager, EventStream);

            //Command handlers registration
            //The command handlers are needed to be registered in the Command Bus,
            //in order to let the XMA framework to invoke and handle commands and events
            //In XVS this is done automatically via MEF, here we need to do it manually
            var handlers = new List <ICommandHandler> {
                new DisconnectServerHandler(ServerSourceManager),
                new RegisterAgentsHandler(ServerSourceManager),
                new RegisterServerSourceHandler(ServerSourceManager, connectionManager),
                new SelectServerHandler(ServerSourceManager),
                new StartAgentHandler(ServerSourceManager),
                new StartConsoleHandler(ServerSourceManager)
            };

            CommandBus = new CommandBus(handlers);

            //This is how we register every server source defined
            CommandBus.Execute(new RegisterServerSource(serverSource, connectAutomatically: true));

            isInitialized = true;
        }
        public TestServerConnectionManager(
            IRemoteServerSourceManager serverSourceManager,
            IAsyncManager asyncManager,
            IEventStream eventStream)
        {
            this.serverSourceManager = serverSourceManager;
            //this.systemEvents = systemEvents;
            //this.solutionState = solutionState;
            this.asyncManager = asyncManager;
            this.eventStream  = eventStream;

            connectionTypes = new ConcurrentDictionary <RemoteServerPlatform, bool>();

            //systemEvents.PowerModeChanged += OnPowerChange;
            //systemEvents.SessionSwitch += OnSessionSwitch;
            //systemEvents.SessionEnded += OnSessionEnded;

            //this.solutionState.SolutionReady += async (sender, args) => {
            //	await CheckServerSourcesAsync ().ConfigureAwait (continueOnCapturedContext: false);
            //};

            //this.solutionState.SolutionClosed += async (sender, args) => {
            //	await DisconnectAsync (unregisterServerSource: true).ConfigureAwait (continueOnCapturedContext: false);
            //};

            eventStream
            .Of <ProjectChanged>()
            .Subscribe(async ev =>
            {
                if (ev.HasProjects)
                {
                    await CheckServerSourceAsync(ev.Platform)
                    .ConfigureAwait(continueOnCapturedContext: false);
                }
            });

            //eventStream
            //	.Of<StartupProjectsChanged> ()
            //	.Subscribe (async ev => {
            //		foreach (var project in ev.StartupProjects) {
            //			await TryConnectAsync (project.GetPlatform ())
            //				.ConfigureAwait (continueOnCapturedContext: false);
            //		}
            //	});
        }