Source/Providers/NFX.MongoDB/Connector/MongoClient.cs
/// <summary>
/// Return a Database instance per supplied connection string in the following form:
/// <code>
/// mongo{server="mongo://localhost:27017" db="myDB"}
/// </code>
/// </summary>
Return a Database instance per supplied connection string in the following form.


Return a Database instance per supplied connection string in the following form .
public static Database DatabaseFromConnectString(string cString)
      {
        if (cString.IsNullOrWhiteSpace())
          throw new MongoDBConnectorException(StringConsts.CONNECTION_STRING_NULL_OR_EMPTY_ERROR);
        var root = cString.AsLaconicConfig();
        if (root == null || !root.IsSameName(CONFIG_CS_ROOT_SECTION))
          throw new MongoDBConnectorException(StringConsts.CONNECTION_STRING_INVALID_ERROR.Args(cString, "Unparsable or not '{0}' root".Args(CONFIG_CS_ROOT_SECTION)));
        var cs = root.AttrByName(CONFIG_CS_SERVER_ATTR).Value;
        var dbn = root.AttrByName(CONFIG_CS_DB_ATTR).Value;
        if (cs.IsNullOrWhiteSpace() || dbn.IsNullOrWhiteSpace())
          throw new MongoDBConnectorException(StringConsts.CONNECTION_STRING_INVALID_ERROR.Args(cString, "Missing attr '{0}' or '{1}'".Args(CONFIG_CS_SERVER_ATTR, CONFIG_CS_DB_ATTR)));
        var server = Instance[ new NFX.Glue.Node(cs)];
        var database = server[dbn];
        return database;
      }
public static Database DatabaseFromConnectString ( string cString ) { if ( cString . IsNullOrWhiteSpace ( ) ) throw new MongoDBConnectorException ( StringConsts . CONNECTION_STRING_NULL_OR_EMPTY_ERROR ) ; var root = cString . AsLaconicConfig ( ) ; if ( root == null || ! root . IsSameName ( CONFIG_CS_ROOT_SECTION ) ) throw new MongoDBConnectorException ( StringConsts . CONNECTION_STRING_INVALID_ERROR . Args ( cString , " " . Args ( CONFIG_CS_ROOT_SECTION ) ) ) ; var cs = root . AttrByName ( CONFIG_CS_SERVER_ATTR ) . Value ; var dbn = root . AttrByName ( CONFIG_CS_DB_ATTR ) . Value ; if ( cs . IsNullOrWhiteSpace ( ) || dbn . IsNullOrWhiteSpace ( ) ) throw new MongoDBConnectorException ( StringConsts . CONNECTION_STRING_INVALID_ERROR . Args ( cString , " " . Args ( CONFIG_CS_SERVER_ATTR , CONFIG_CS_DB_ATTR ) ) ) ; var server = Instance [ new NFX . Glue . Node ( cs ) ] ; var database = server [ dbn ] ; return database ; }
Return a Database instance per supplied connection string in the following form:
Return a Database instance per supplied connection string in the following form :
cString
string