MongoDB.Driver.MongoUrlBuilder.ToMongoUrl C# (CSharp) Méthode

ToMongoUrl() public méthode

Creates a new instance of MongoUrl based on the settings in this MongoUrlBuilder.
public ToMongoUrl ( ) : MongoDB.Driver.MongoUrl
Résultat MongoDB.Driver.MongoUrl
        public MongoUrl ToMongoUrl()
        {
            return MongoUrl.Create(ToString());
        }

Usage Example

        /// <summary>
        /// Initializes a new instance of the <see cref="JobStore"/> class.
        /// </summary>
        public JobStore()
        {
            log = LogManager.GetLogger(GetType());

            string connectionString;

            if( ConfigurationManager.ConnectionStrings["quartznet-mongodb"] != null )
                connectionString = ConfigurationManager.ConnectionStrings["quartznet-mongodb"].ConnectionString;
            else
                connectionString = DefaultConnectionString;

            //
            // If there is no connection string to use then throw an 
            // exception to abort construction.
            //

            if (string.IsNullOrWhiteSpace(connectionString))
                throw new ApplicationException("Connection string is missing for the MongoDB job store.");

            lock (lockObject)
            {
                var urlBuilder = new MongoUrlBuilder(connectionString);
                var client = new MongoClient(urlBuilder.ToMongoUrl());
                this.database = client.GetServer().GetDatabase(urlBuilder.DatabaseName);
            }
        }
All Usage Examples Of MongoDB.Driver.MongoUrlBuilder::ToMongoUrl