private static bool GetHostConnectionData(string applicationPath, out HostConnectionData connectionData)
        {
            if (HostConnectionUtil.FindHostConnection(applicationPath, out connectionData))
            {
                return(EnsureHostServerStarted(applicationPath, ref connectionData));
            }

            connectionData = null;
            return(false);
        }
Ejemplo n.º 2
0
        private static bool ConnectionContainsApplication(HostConnectionData connection, string applicationPhysicalPath)
        {
            foreach (string projectPath in connection.ProjectPaths)
            {
                if (PathUtil.CompareNormalizedPaths(applicationPhysicalPath, projectPath))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        internal static bool ParseV1ConnectionData(string instanceFileName, List <string> lines, out HostConnectionData connection)
        {
            if (lines.Count > 2)
            {
                string connectionString;
                string sslConnectionString;
                string requestSignalName;
                string readySignalName;
                string injectScriptVerb;
                string mappingDataVerb;
                string serverDataVerb;
                IEnumerable <string> projectPaths;

                CreateConnectionStringsAndProjectPaths(
                    lines,
                    out connectionString,
                    out sslConnectionString,
                    out projectPaths);

                CreateSignalNames(
                    instanceFileName,
                    out requestSignalName,
                    out readySignalName);

                CreateVerbUrls(
                    V1DefaultProperties,
                    connectionString,
                    out injectScriptVerb,
                    out mappingDataVerb,
                    out serverDataVerb);

                connection = new HostConnectionData(
                    connectionString,
                    sslConnectionString,
                    requestSignalName,
                    readySignalName,
                    injectScriptVerb,
                    mappingDataVerb,
                    serverDataVerb,
                    projectPaths);

                return(true);
            }

            connection = null;
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Send a signal to the host to make sure it is running.
        /// </summary>
        /// <param name="connection">The connection to signal.</param>
        /// <param name="blockUntilStarted">If true, this method will not return until the host signals it is ready</param>
        /// <returns>True if the handle was successfully signaled, and the host server is ready</returns>
        internal static bool SignalHostForStartup(HostConnectionData connection, bool blockUntilStarted)
        {
            if (connection.RequestSignalName != null &&
                connection.ReadySignalName != null)
            {
                SendSignal(connection.RequestSignalName);

                if (blockUntilStarted)
                {
                    return(WaitForSignal(connection.ReadySignalName));
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Find the host connection for an ASP.NET application.
        /// </summary>
        /// <param name="applicationPhysicalPath">The physical root path of the application</param>
        /// <param name="connection">The connection that is found.</param>
        /// <returns>True if a connection is found for the given application.</returns>
        internal static bool FindHostConnection(string applicationPhysicalPath, out HostConnectionData connection)
        {
            applicationPhysicalPath = PathUtil.NormalizeDirectoryPath(applicationPhysicalPath);

            foreach (string instanceFileName in GetAllInstanceFileNames())
            {
                foreach (HostConnectionData connectionCandidate in ReadConnectionData(instanceFileName))
                {
                    if (ConnectionContainsApplication(connectionCandidate, applicationPhysicalPath))
                    {
                        connection = connectionCandidate;
                        return(true);
                    }
                }
            }

            connection = null;
            return(false);
        }
        private static bool EnsureHostServerStarted(string applicationPath, ref HostConnectionData connectionData)
        {
            if (String.IsNullOrEmpty(connectionData.ConnectionString))
            {
                if (!HostConnectionUtil.SignalHostForStartup(connectionData))
                {
                    return(false);
                }

                if (!HostConnectionUtil.FindHostConnection(applicationPath, out connectionData))
                {
                    return(false);
                }

                if (String.IsNullOrEmpty(connectionData.ConnectionString))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Send a signal to the host to make sure it is running.
 /// </summary>
 /// <param name="connection">The connection to signal.</param>
 /// <returns>True if the handle was successfully signaled, and the host server is ready</returns>
 internal static bool SignalHostForStartup(HostConnectionData connection)
 {
     return(SignalHostForStartup(connection, blockUntilStarted: true));
 }
Ejemplo n.º 8
0
        private static bool ReadV1ConnectionData(string instanceFileName, out HostConnectionData connection)
        {
            List <string> lines = ReadAllLinesFrom(instanceFileName);

            return(ParseV1ConnectionData(instanceFileName, lines, out connection));
        }