示例#1
0
        public DesignTimeHostCompiler(ApplicationShutdown shutdown, IFileWatcher watcher, Stream stream)
        {
            _shutdown = shutdown;
            _queue    = new ProcessingQueue(stream);
            _queue.ProjectCompiled     += OnProjectCompiled;
            _queue.ProjectsInitialized += ProjectContextsInitialized;
            _queue.ProjectChanged      += _ => shutdown.RequestShutdownWaitForDebugger();
            _queue.ProjectSources      += files =>
            {
                foreach (var file in files)
                {
                    watcher.WatchFile(file);
                }
            };
            _queue.Error += OnError;

            _queue.Closed += OnClosed;
            _queue.Start();

            var obj = new JObject();

            obj["Version"] = 1;

            _queue.Send(new DesignTimeMessage
            {
                HostId      = "Application",
                MessageType = "EnumerateProjectContexts",
                Payload     = obj
            });
        }
示例#2
0
        public DesignTimeHostCompiler(ApplicationShutdown shutdown, IFileWatcher watcher, Stream stream)
        {
            _shutdown = shutdown;
            _queue = new ProcessingQueue(stream);
            _queue.ProjectCompiled += OnProjectCompiled;
            _queue.ProjectsInitialized += ProjectContextsInitialized;
            _queue.ProjectChanged += _ => shutdown.RequestShutdownWaitForDebugger();
            _queue.ProjectSources += files =>
            {
                foreach (var file in files)
                {
                    watcher.WatchFile(file);
                }
            };
            _queue.Error += OnError;

            _queue.Closed += OnClosed;
            _queue.Start();

            var obj = new JObject();
            obj["Version"] = 1;

            _queue.Send(new DesignTimeMessage
            {
                HostId = "Application",
                MessageType = "EnumerateProjectContexts",
                Payload = obj
            });
        }
示例#3
0
        private void Initialize(DefaultHostOptions options, IServiceProvider hostServices)
        {
            var cacheContextAccessor = new CacheContextAccessor();
            var cache = new Cache(cacheContextAccessor);
            var namedCacheDependencyProvider = new NamedCacheDependencyProvider();

            _applicationHostContext = new ApplicationHostContext(
                hostServices,
                _projectDirectory,
                options.PackageDirectory,
                options.Configuration,
                _targetFramework,
                cache,
                cacheContextAccessor,
                namedCacheDependencyProvider);

            Logger.TraceInformation("[{0}]: Project path: {1}", GetType().Name, _projectDirectory);
            Logger.TraceInformation("[{0}]: Project root: {1}", GetType().Name, _applicationHostContext.RootDirectory);
            Logger.TraceInformation("[{0}]: Packages path: {1}", GetType().Name, _applicationHostContext.PackagesDirectory);

            _project = _applicationHostContext.Project;

            if (Project == null)
            {
                throw new Exception("Unable to locate " + Project.ProjectFileName);
            }

            if (options.WatchFiles)
            {
                var watcher = new FileWatcher(_applicationHostContext.RootDirectory);
                _watcher           = watcher;
                watcher.OnChanged += _ =>
                {
                    _shutdown.RequestShutdownWaitForDebugger();
                };
            }
            else
            {
                _watcher = NoopWatcher.Instance;
            }

            _applicationHostContext.AddService(typeof(IApplicationShutdown), _shutdown);
            _applicationHostContext.AddService(typeof(IRuntimeOptions), options);

            // TODO: Get rid of this and just use the IFileWatcher
            _applicationHostContext.AddService(typeof(IFileMonitor), _watcher);
            _applicationHostContext.AddService(typeof(IFileWatcher), _watcher);

            if (options.CompilationServerPort.HasValue)
            {
                // Change the project reference provider
                Project.DefaultCompiler = Project.DefaultDesignTimeCompiler;
            }

            CallContextServiceLocator.Locator.ServiceProvider = ServiceProvider;
        }
示例#4
0
        private void Initialize(DefaultHostOptions options, IServiceProvider hostServices)
        {
            _applicationHostContext = new ApplicationHostContext(
                hostServices,
                _projectDirectory,
                options.PackageDirectory,
                options.Configuration,
                _targetFramework);

            Trace.TraceInformation("[{0}]: Project path: {1}", GetType().Name, _projectDirectory);
            Trace.TraceInformation("[{0}]: Project root: {1}", GetType().Name, _applicationHostContext.RootDirectory);
            Trace.TraceInformation("[{0}]: Packages path: {1}", GetType().Name, _applicationHostContext.PackagesDirectory);

            _project = _applicationHostContext.Project;

            if (Project == null)
            {
                throw new Exception("Unable to locate " + Project.ProjectFileName);
            }

            if (options.WatchFiles)
            {
                var watcher = new FileWatcher(_applicationHostContext.RootDirectory);
                _watcher           = watcher;
                watcher.OnChanged += _ =>
                {
                    _shutdown.RequestShutdownWaitForDebugger();
                };
            }
            else
            {
                _watcher = NoopWatcher.Instance;
            }

            var applicationEnvironment = new ApplicationEnvironment(Project, _targetFramework, options.Configuration);

            _applicationHostContext.AddService(typeof(IApplicationEnvironment), applicationEnvironment);
            _applicationHostContext.AddService(typeof(IApplicationShutdown), _shutdown);
            // TODO: Get rid of this and just use the IFileWatcher
            _applicationHostContext.AddService(typeof(IFileMonitor), _watcher);
            _applicationHostContext.AddService(typeof(IFileWatcher), _watcher);

            CallContextServiceLocator.Locator.ServiceProvider = ServiceProvider;
        }
示例#5
0
        private void Initialize(DefaultHostOptions options, IServiceProvider hostServices)
        {
            var cacheContextAccessor = new CacheContextAccessor();
            var cache = new Cache(cacheContextAccessor);
            var namedCacheDependencyProvider = new NamedCacheDependencyProvider();

            _applicationHostContext = new ApplicationHostContext(
                hostServices,
                _projectDirectory,
                options.PackageDirectory,
                options.Configuration,
                _targetFramework,
                cache,
                cacheContextAccessor,
                namedCacheDependencyProvider);

            Logger.TraceInformation("[{0}]: Project path: {1}", GetType().Name, _projectDirectory);
            Logger.TraceInformation("[{0}]: Project root: {1}", GetType().Name, _applicationHostContext.RootDirectory);
            Logger.TraceInformation("[{0}]: Packages path: {1}", GetType().Name, _applicationHostContext.PackagesDirectory);

            _project = _applicationHostContext.Project;

            if (Project == null)
            {
                throw new Exception("Unable to locate " + Project.ProjectFileName);
            }

            if (options.WatchFiles)
            {
                var watcher = new FileWatcher(_applicationHostContext.RootDirectory);
                _watcher           = watcher;
                watcher.OnChanged += _ =>
                {
                    _shutdown.RequestShutdownWaitForDebugger();
                };
            }
            else
            {
                _watcher = NoopWatcher.Instance;
            }

            _applicationHostContext.AddService(typeof(IApplicationShutdown), _shutdown);
            // TODO: Get rid of this and just use the IFileWatcher
            _applicationHostContext.AddService(typeof(IFileMonitor), _watcher);
            _applicationHostContext.AddService(typeof(IFileWatcher), _watcher);

            if (options.CompilationServerPort.HasValue)
            {
                // Using this ctor because it works on mono, this is hard coded to ipv4
                // right now. Mono will eventually have the dualmode overload
                var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Connect(new IPEndPoint(IPAddress.Loopback, options.CompilationServerPort.Value));

                var networkStream = new NetworkStream(socket);

                _applicationHostContext.AddService(typeof(IDesignTimeHostCompiler),
                                                   new DesignTimeHostCompiler(_shutdown, _watcher, networkStream), includeInManifest: false);

                // Change the project reference provider
                Project.DefaultLanguageService = new TypeInformation(
                    typeof(DefaultHost).GetTypeInfo().Assembly.GetName().Name,
                    typeof(DesignTimeHostProjectReferenceProvider).FullName);
            }

            CallContextServiceLocator.Locator.ServiceProvider = ServiceProvider;
        }