Ejemplo n.º 1
0
 public bool IsServerReachable(int handle, int timeout)
 {
     WebServerService.BrowsingSession browsingSession = this.GetBrowsingSession(handle);
     if (browsingSession != null && !browsingSession.process.HasExited)
     {
         return(this.CanConnectToPort(new Uri(browsingSession.Uri).Port, timeout));
     }
     return(false);
 }
Ejemplo n.º 2
0
        public string GetSessionAddress(int handle, string localPath)
        {
            WebServerService.BrowsingSession browsingSession = this.GetBrowsingSession(handle);
            if (browsingSession == null)
            {
                return((string)null);
            }
            if (localPath == null)
            {
                return(browsingSession.Uri);
            }
            string originalString = new Uri(browsingSession.localPath + (object)Path.DirectorySeparatorChar, UriKind.Absolute).MakeRelativeUri(new Uri(localPath, UriKind.Absolute)).OriginalString;

            return(new Uri(browsingSession.Uri + originalString, UriKind.Absolute).OriginalString);
        }
Ejemplo n.º 3
0
        public int StartServer(IWebServerSettings settings)
        {
            foreach (WebServerService.BrowsingSession browsingSession in this._listSessions)
            {
                if (string.CompareOrdinal(browsingSession.localPath, settings.LocalPath) == 0 && !browsingSession.process.HasExited)
                {
                    return(browsingSession.Handle);
                }
            }
            WebServerService.BrowsingSession browsingSession1 = new WebServerService.BrowsingSession();
            if (Microsoft.Expression.Framework.Documents.PathHelper.PathEndsInDirectorySeparator(settings.LocalPath))
            {
                settings.LocalPath = Microsoft.Expression.Framework.Documents.PathHelper.TrimTrailingDirectorySeparators(settings.LocalPath);
            }
            browsingSession1.localPath = settings.LocalPath;
            int num = settings.Port;

            if (num == 0)
            {
                num = this.GetNextAvailPort();
            }
            ProcessStartInfo startInfo = new ProcessStartInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Microsoft.Expression.WebServer.exe", " /port:" + (object)num + (" /path:\"" + settings.LocalPath + "\"") + (" /vpath:\"" + settings.VirtualPath + "\"") + (settings.ShowTrayIcon ? (string)null : " /nosystray") + (!string.IsNullOrEmpty(settings.PhpServerExe) ? " /php:\"" + settings.PhpServerExe + "\"" : (string)null) + (settings.Silent ? " /silent" : (string)null) + (settings.UseNtlmAuthentication ? " /ntlm" : (string)null) + (settings.ShowDirectoryListing ? (string)null : " /nodirlist"));

            try
            {
                browsingSession1.process = Process.Start(startInfo);
                browsingSession1.Uri     = "http://localhost:" + (object)num + "/";
                browsingSession1.Handle  = ++WebServerService.g_Handle;
                this._listSessions.Add(browsingSession1);
            }
            catch (Win32Exception ex)
            {
                IMessageDisplayService service = this.services.GetService <IMessageDisplayService>();
                if (service != null)
                {
                    service.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.WebServerCannotLaunch, new object[1]
                    {
                        (object)settings.LocalPath
                    }));
                }
                return(0);
            }
            return(browsingSession1.Handle);
        }