Exemple #1
0
        private async Task OpenChannel(int port, string hostId)
        {
            var contexts        = new Dictionary <int, ApplicationContext>();
            var protocolManager = new ProtocolManager(maxVersion: 3);

            // REVIEW: Should these be on a shared context object that flows?
            var applicationEnvironment = (IApplicationEnvironment)_services.GetService(typeof(IApplicationEnvironment));
            var runtimeEnvironment     = (IRuntimeEnvironment)_services.GetService(typeof(IRuntimeEnvironment));
            var loadContextAccessor    = (IAssemblyLoadContextAccessor)_services.GetService(typeof(IAssemblyLoadContextAccessor));
            var compilationEngine      = new CompilationEngine(new CompilationEngineContext(applicationEnvironment, runtimeEnvironment, loadContextAccessor.Default, new CompilationCache()));
            var frameworkResolver      = new FrameworkReferenceResolver();

            // This fixes the mono incompatibility but ties it to ipv4 connections
            var listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, port));
            listenSocket.Listen(10);

            Console.WriteLine($"Process ID {Process.GetCurrentProcess().Id}");
            Console.WriteLine("Listening on port {0}", port);

            while (true)
            {
                var acceptSocket = await AcceptAsync(listenSocket);

                Console.WriteLine("Client accepted {0}", acceptSocket.LocalEndPoint);

                var stream     = new NetworkStream(acceptSocket);
                var queue      = new ProcessingQueue(stream);
                var connection = new ConnectionContext(
                    contexts,
                    _services,
                    applicationEnvironment,
                    runtimeEnvironment,
                    loadContextAccessor,
                    frameworkResolver,
                    queue,
                    protocolManager,
                    compilationEngine,
                    hostId);

                queue.OnReceive += message =>
                {
                    // Enumerates all project contexts and return them to the
                    // sender
                    if (message.MessageType == "EnumerateProjectContexts")
                    {
                        WriteProjectContexts(message, queue, contexts);
                    }
                    else
                    {
                        // Otherwise it's a context specific message
                        connection.OnReceive(message);
                    }
                };

                queue.Start();
            }
        }
Exemple #2
0
        private async Task OpenChannel(int port, string hostId)
        {
            var contexts = new Dictionary<int, ApplicationContext>();
            var protocolManager = new ProtocolManager(maxVersion: 3);

            // REVIEW: Should these be on a shared context object that flows?
            var applicationEnvironment = (IApplicationEnvironment)_services.GetService(typeof(IApplicationEnvironment));
            var runtimeEnvironment = (IRuntimeEnvironment)_services.GetService(typeof(IRuntimeEnvironment));
            var loadContextAccessor = (IAssemblyLoadContextAccessor)_services.GetService(typeof(IAssemblyLoadContextAccessor));
            var compilationEngine = new CompilationEngine(new CompilationEngineContext(applicationEnvironment, runtimeEnvironment, loadContextAccessor.Default, new CompilationCache()));
            var frameworkResolver = new FrameworkReferenceResolver();

            // This fixes the mono incompatibility but ties it to ipv4 connections
            var listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, port));
            listenSocket.Listen(10);

            Console.WriteLine($"Process ID {Process.GetCurrentProcess().Id}");
            Console.WriteLine("Listening on port {0}", port);

            while (true)
            {
                var acceptSocket = await AcceptAsync(listenSocket);

                Console.WriteLine("Client accepted {0}", acceptSocket.LocalEndPoint);

                var stream = new NetworkStream(acceptSocket);
                var queue = new ProcessingQueue(stream);
                var connection = new ConnectionContext(
                    contexts,
                    _services,
                    applicationEnvironment,
                    runtimeEnvironment,
                    loadContextAccessor,
                    frameworkResolver,
                    queue,
                    protocolManager,
                    compilationEngine,
                    hostId);

                queue.OnReceive += message =>
                {
                    // Enumerates all project contexts and return them to the
                    // sender
                    if (message.MessageType == "EnumerateProjectContexts")
                    {
                        WriteProjectContexts(message, queue, contexts);
                    }
                    else
                    {
                        // Otherwise it's a context specific message
                        connection.OnReceive(message);
                    }
                };

                queue.Start();
            }
        }
Exemple #3
0
 public ConnectionContext(IDictionary <int, ApplicationContext> contexts,
                          IServiceProvider services,
                          ProcessingQueue queue,
                          ProtocolManager protocolManager,
                          string hostId)
 {
     _contexts        = contexts;
     _services        = services;
     _queue           = queue;
     _hostId          = hostId;
     _protocolManager = protocolManager;
     _cache           = new CompilationCache();
 }
Exemple #4
0
 public ConnectionContext(IDictionary<int, ApplicationContext> contexts,
                          IServiceProvider services,
                          ProcessingQueue queue,
                          ProtocolManager protocolManager,
                          string hostId)
 {
     _contexts = contexts;
     _services = services;
     _queue = queue;
     _hostId = hostId;
     _protocolManager = protocolManager;
     _cache = new CompilationCache();
 }
Exemple #5
0
        private async Task OpenChannel(int port, string hostId)
        {
            var contexts        = new Dictionary <int, ApplicationContext>();
            var services        = new ServiceProvider(_services);
            var protocolManager = new ProtocolManager(maxVersion: 2);

            // This fixes the mono incompatibility but ties it to ipv4 connections
            var listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, port));
            listenSocket.Listen(10);

            Console.WriteLine($"Process ID {Process.GetCurrentProcess().Id}");
            Console.WriteLine("Listening on port {0}", port);

            for (; ;)
            {
                var acceptSocket = await AcceptAsync(listenSocket);

                Console.WriteLine("Client accepted {0}", acceptSocket.LocalEndPoint);

                var stream     = new NetworkStream(acceptSocket);
                var queue      = new ProcessingQueue(stream);
                var connection = new ConnectionContext(
                    contexts,
                    services,
                    queue,
                    protocolManager,
                    hostId);

                queue.OnReceive += message =>
                {
                    // Enumerates all project contexts and return them to the
                    // sender
                    if (message.MessageType == "EnumerateProjectContexts")
                    {
                        WriteProjectContexts(message, queue, contexts);
                    }
                    else
                    {
                        // Otherwise it's a context specific message
                        connection.OnReceive(message);
                    }
                };

                queue.Start();
            }
        }
Exemple #6
0
        private async Task OpenChannel(int port, string hostId)
        {
            var contexts = new Dictionary<int, ApplicationContext>();
            var services = new ServiceProvider(_services);
            var protocolManager = new ProtocolManager(maxVersion: 2);

            // This fixes the mono incompatibility but ties it to ipv4 connections
            var listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, port));
            listenSocket.Listen(10);

            Console.WriteLine($"Process ID {Process.GetCurrentProcess().Id}");
            Console.WriteLine("Listening on port {0}", port);

            for (; ;)
            {
                var acceptSocket = await AcceptAsync(listenSocket);

                Console.WriteLine("Client accepted {0}", acceptSocket.LocalEndPoint);

                var stream = new NetworkStream(acceptSocket);
                var queue = new ProcessingQueue(stream);
                var connection = new ConnectionContext(
                    contexts,
                    services,
                    queue,
                    protocolManager,
                    hostId);

                queue.OnReceive += message =>
                {
                    // Enumerates all project contexts and return them to the
                    // sender
                    if (message.MessageType == "EnumerateProjectContexts")
                    {
                        WriteProjectContexts(message, queue, contexts);
                    }
                    else
                    {
                        // Otherwise it's a context specific message
                        connection.OnReceive(message);
                    }
                };

                queue.Start();
            }
        }
Exemple #7
0
 public ConnectionContext(IDictionary <int, ApplicationContext> contexts,
                          IServiceProvider services,
                          IApplicationEnvironment applicationEnvironment,
                          IAssemblyLoadContextAccessor loadContextAccessor,
                          FrameworkReferenceResolver frameworkResolver,
                          ProcessingQueue queue,
                          ProtocolManager protocolManager,
                          CompilationEngine compilationEngine,
                          string hostId)
 {
     _contexts = contexts;
     _services = services;
     _applicationEnvironment = applicationEnvironment;
     _loadContextAccessor    = loadContextAccessor;
     _frameworkResolver      = frameworkResolver;
     _queue             = queue;
     _compilationEngine = compilationEngine;
     _protocolManager   = protocolManager;
     _compilationEngine = compilationEngine;
     _hostId            = hostId;
 }
Exemple #8
0
 public ConnectionContext(IDictionary<int, ApplicationContext> contexts,
                          IServiceProvider services,
                          IApplicationEnvironment applicationEnvironment,
                          IAssemblyLoadContextAccessor loadContextAccessor,
                          FrameworkReferenceResolver frameworkResolver,
                          ProcessingQueue queue,
                          ProtocolManager protocolManager,
                          CompilationEngine compilationEngine,
                          string hostId)
 {
     _contexts = contexts;
     _services = services;
     _applicationEnvironment = applicationEnvironment;
     _loadContextAccessor = loadContextAccessor;
     _frameworkResolver = frameworkResolver;
     _queue = queue;
     _compilationEngine = compilationEngine;
     _protocolManager = protocolManager;
     _compilationEngine = compilationEngine;
     _hostId = hostId;
 }
Exemple #9
0
        public ApplicationContext(IServiceProvider services,
                                  IApplicationEnvironment applicationEnvironment,
                                  IRuntimeEnvironment runtimeEnvironment,
                                  IAssemblyLoadContextAccessor loadContextAccessor,
                                  ProtocolManager protocolManager,
                                  CompilationEngine compilationEngine,
                                  FrameworkReferenceResolver frameworkResolver,
                                  int id)
        {
            _applicationEnvironment = applicationEnvironment;
            _runtimeEnvironment     = runtimeEnvironment;
            _defaultLoadContext     = loadContextAccessor.Default;
            _pluginHandler          = new PluginHandler(services, SendPluginMessage);
            _protocolManager        = protocolManager;
            _compilationEngine      = compilationEngine;
            _frameworkResolver      = frameworkResolver;
            Id = id;

            _projectStateResolver = new ProjectStateResolver(
                _compilationEngine,
                _frameworkResolver,
                (ctx, project, frameworkName) => CreateApplicationHostContext(ctx, project, frameworkName, Enumerable.Empty <string>()));
        }