private KeyValuePair <string, ImageSource> GetImageSourceForFileExtension(string fileExtension)
        {
            var         list   = DefaultIconImageList.Instance;
            ImageSource source = list.GetImage(fileExtension);

            if (source != null)
            {
                return(new KeyValuePair <string, ImageSource>(fileExtension, source));
            }

            source = list.GetImage(".txt");
            if (source != null)
            {
                return(new KeyValuePair <string, ImageSource>(".txt", source));
            }

            source = GetImageSource("TextDocument");
            Invariants.CheckOperation(source != null, "Text Document icon is missing");
            return(new KeyValuePair <string, ImageSource>("TextDocument", source));
        }
        private void AfterProxyCreated(CreateProcessResult processResult)
        {
            Invariants.Assert(processResult != null);

            Logger.LogInfo("AfterProxyCreated (pid={0}", processResult.Process.Id);
#if PROFILE_SERVER
            var timeout = TimeSpan.FromSeconds(120.0);
            System.Diagnostics.Trace.WriteLine(string.Format(
                                                   "You have {0:n0} seconds to start the server process with a port argument of {1}.", timeout.TotalSeconds,
                                                   ((IPEndPoint)_tcpListener.LocalEndpoint).Port));
#else
            var timeout = TimeSpan.FromSeconds(30.0);
#endif
            Logger.LogInfo("AfterProxyCreated: Wait for TCP client connection from server process.");
            var serverStartedSuccessfully = _waitForConnection.WaitOne(timeout) && _tcpClient != null;
            Invariants.CheckOperation(serverStartedSuccessfully, $"Child process did not connect to server within {timeout.TotalSeconds:n0} seconds.");

            _ipcStream = new IpcStreamOverNetworkStream(_serializer, _tcpClient.GetStream());

            // Ensure process is alive and ready to process requests
            Logger.LogInfo("AfterProxyCreated: Wait for \"Hello\" message from server process.");
            WaitForProcessHelloMessage();

            // Start reading process output
            Logger.LogInfo("AfterProxyCreated: Start receive response thread.");
            _receiveResponsesThread.ResponseReceived += response => {
                var callback = _callbacks.Remove(response.RequestId);
                callback(response);
            };
            _receiveResponsesThread.EventReceived += @event => { OnEventReceived(@event); };
            _receiveResponsesThread.FatalError    += (sender, args) => { HandleReceiveThreadFatalError(args); };
            _receiveResponsesThread.Start(_ipcStream);

            Logger.LogInfo("AfterProxyCreated: Start send request thread..");
            _sendRequestsThread.SendRequestError += HandleSendRequestError;
            _sendRequestsThread.Start(_ipcStream, _requestQueue);

            // Server is fully started, notify consumers
            _isServerRunning = true;
            OnProcessStarted();
        }
        private KeyValuePair <string, ImageSource> GetImageSourceForFileExtension(string fileExtension)
        {
            // TODO: Fix this to work with v14 for VS SDK

            /*
             * var list = DefaultIconImageList.Instance;
             * ImageSource source = list.GetImage(fileExtension);
             * if (source != null) {
             * return new KeyValuePair<string, ImageSource>(fileExtension, source);
             * }
             *
             * source = list.GetImage(".txt");
             * if (source != null) {
             * return new KeyValuePair<string, ImageSource>(".txt", source);
             * }
             */

            ImageSource source = GetImageSource("TextDocument");

            Invariants.CheckOperation(source != null, "Text Document icon is missing");
            return(new KeyValuePair <string, ImageSource>("TextDocument", source));
        }
Exemple #4
0
        private RelativePath BuildRelativePath()
        {
            Invariants.CheckOperation(_parent != null, "File name is invalid (uninitialized value type)");

            // Aquire the StringBuilder from thread static variable.
            if (_dangerousThreadStaticStringBuilder == null)
            {
                _dangerousThreadStaticStringBuilder = new StringBuilder(128);
            }
            var sb = _dangerousThreadStaticStringBuilder;

            sb.Clear();

            // Build the relative path
            DirectoryName.BuildRelativePath(sb, _parent);
            if (sb.Length > 0)
            {
                sb.Append(PathHelpers.DirectorySeparatorChar);
            }
            sb.Append(_name);
            return(new RelativePath(sb.ToString()));
        }
 protected override void AddChildImpl(NodeViewModel node)
 {
     Invariants.CheckOperation(false, "Cannot add child node to a file node");
 }