Beispiel #1
0
        /// <summary>
        ///   It returns the namespace name from a give set of connection string properties.
        /// </summary>
        ///
        /// <param name="connectionString">The connection string to be parsed.</param>
        ///
        /// <returns>The namespace name for a given connection string.</returns>
        ///
        private static string ParseNamespaceName(string connectionString)
        {
            string fqdn = ConnectionStringTokenParser.ParseTokenAndReturnValue(connectionString, "Endpoint");

            if (!string.IsNullOrEmpty(fqdn))
            {
                return(ConnectionStringTokenParser.ParseNamespaceName(fqdn));
            }

            return(null);
        }
        /// <summary>
        ///   It removes the entity path from a event hub connection string if found.
        ///   It returns the same connection string.
        /// </summary>
        ///
        /// <param name="connectionString">The connection string to parse.</param>
        ///
        /// <returns>A namespace scoped connection string.</returns>
        ///
        private static string ParseNamespaceConnectionString(string connectionString)
        {
            string entityPath = ConnectionStringTokenParser.ParseToken(connectionString, "EntityPath");

            if (!string.IsNullOrEmpty(entityPath))
            {
                return(connectionString.Replace(entityPath, string.Empty));
            }

            return(connectionString);
        }
 /// <summary>
 ///   Parses a well-formed connection string to extract the shared access key.
 /// </summary>
 /// <param name="connectionString"></param>
 ///
 /// <returns>The fully qualified namespace contained in the connection string if the connection string is well-formed; otherwise, a <see cref="InvalidOperationException" /> is thrown.</returns>
 ///
 private static string ParseSharedAccessKey(string connectionString) =>
 ConnectionStringTokenParser.ParseTokenAndReturnValue(connectionString, "SharedAccessKey");
 /// <summary>
 ///   Parses a well-formed connection string to extract the fully qualified namespace.
 /// </summary>
 ///
 /// <param name="connectionString">The connection string to parse.</param>
 ///
 /// <returns>The fully qualified namespace contained in the connection string if the connection string is well-formed; otherwise, a <see cref="InvalidOperationException" /> is thrown.</returns>
 ///
 private static string ParseFullyQualifiedNamespace(string connectionString) =>
 new Uri(ConnectionStringTokenParser.ParseTokenAndReturnValue(connectionString, "Endpoint")).Host;