private bool NavigateToFileUsingHelperProcess(string path, int lineNumber, int columnNumber)
        {
            var command = GallioNavigatorCommand.CreateNavigateToCommand(path, lineNumber, columnNumber);

            string navigatorExePath = AssemblyUtils.GetFriendlyAssemblyLocation(GetType().Assembly);
            string navigatorArgs    = command.ToUri();

            System.Diagnostics.Process.Start(navigatorExePath, navigatorArgs);
            return(true);
        }
Beispiel #2
0
        internal int Run(string[] args)
        {
            if (args.Length != 1)
            {
                ShowHelp();
                return(1);
            }

            GallioNavigatorCommand command = GallioNavigatorCommand.ParseUri(args[0]);

            if (command == null)
            {
                return(1);
            }

            IGallioNavigator engine = CreateNavigatorEngine();

            return(command.Execute(engine) ? 0 : 1);
        }
        private int DoBind()
        {
            currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_FINDINGRESOURCE, currentUrl);
            currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_CONNECTING, "Gallio Navigator.");

            bool success = false;

            try
            {
                GallioNavigatorCommand command = GallioNavigatorCommand.ParseUri(currentUrl);
                if (command != null)
                {
                    if (command.Name == "openAttachment")
                    {
                        string path = command.Arguments["path"];
                        if (!string.IsNullOrEmpty(path))
                        {
                            currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_SENDINGREQUEST, Path.GetFileName(path));
                            success = StartOpenAttachmentCommand(path);
                        }
                    }
                    else
                    {
                        currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_SENDINGREQUEST, command.Name);

                        var engine = new GallioNavigatorEngine(true);
                        success = command.Execute(engine);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("Failed to process Uri '{0}' due to an exception: {1}.", currentUrl, ex));
            }

            LockData();

            int hr;

            if (success)
            {
                if (data != null && (currentBindFlags & BINDF.BINDF_NOWRITECACHE) == 0)
                {
                    uint dataLength = (uint)data.Length;

                    // Provide mime type.
                    if (dataMimeType != null)
                    {
                        currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, dataMimeType);
                    }

                    // Determine whether we need to provide the path to the local file.
                    if ((currentBindFlags & BINDF.BINDF_NEEDFILE) != 0 && dataPath != null)
                    {
#if false // Not needed at the moment since the file we provide does not need to be in the cache.
          // Keeping this code in case we decide to provide dynamic content later.
                        StringBuilder cacheFilePathBuilder = new StringBuilder(NativeConstants.MAX_PATH);
                        string        extension            = Path.GetExtension(dataPath);
                        if (extension.Length != 0)
                        {
                            extension = extension.Substring(1); // strip leading '.'
                        }
                        NativeMethods.CreateUrlCacheEntry(currentUrl, dataLength, extension, cacheFilePathBuilder, 0);
                        string cacheFilePath = cacheFilePathBuilder.ToString();

                        DateTime now     = DateTime.Now;
                        var      nowTime = new System.Runtime.InteropServices.ComTypes.FILETIME()
                        {
                            dwHighDateTime = (int)(now.Ticks >> 32),
                            dwLowDateTime  = (int)now.Ticks
                        };

                        const string headers = "HTTP/1.0 200 OK\r\n\r\n";
                        File.Copy(dataPath, cacheFilePath, true);
                        NativeMethods.CommitUrlCacheEntry(currentUrl, cacheFilePath,
                                                          nowTime,
                                                          nowTime,
                                                          NativeConstants.NORMAL_CACHE_ENTRY,
                                                          headers, (uint)headers.Length,
                                                          extension, null);

                        currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_CACHEFILENAMEAVAILABLE, cacheFilePath);
#else
                        currentProtocolSink.ReportProgress(BINDSTATUS.BINDSTATUS_CACHEFILENAMEAVAILABLE, dataPath);
#endif
                    }

                    // Report all data available.
                    currentProtocolSink.ReportData(BSCF.BSCF_FIRSTDATANOTIFICATION | BSCF.BSCF_LASTDATANOTIFICATION | BSCF.BSCF_DATAFULLYAVAILABLE, dataLength, dataLength);

                    hr = NativeConstants.S_OK;
                }
                else
                {
                    // Aborts the navigation.
                    hr = NativeConstants.INET_E_DATA_NOT_AVAILABLE;
                }
            }
            else
            {
                // Reports an invalid Url.
                hr = NativeConstants.INET_E_INVALID_URL;
            }

            currentProtocolSink.ReportResult(hr, 0, null);
            currentProtocolSink = null;

            UnlockData();
            return(hr);
        }