示例#1
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);
        }
示例#2
0
 public static void Initialize(IWebServerSettings webServerSettings)
 {
     _webServerSettings = webServerSettings;
 }
示例#3
0
 public WebServer(ILog log, IWebServerSettings settings)
 {
     _log = log;
     _settings = settings;
     _httpServer = new HttpServer(new[] {settings.Url}, ProcessRequest);
 }
示例#4
0
 public AuthenticationService()
 {
     _serverSettings = ServiceFactory.GetExportedService <IWebServerSettings>();
 }