Inheritance: CommonCore.Configuration.AutoConfigurationSection
Exemplo n.º 1
0
		/// <summary>
		/// Gets the database connection string.
		/// </summary>
		/// <param name="config">The config.</param>
		/// <returns></returns>
		internal static string GetDatabaseConnectionString(MongoDbWebSection mongoDbWebSection, NameValueCollection config)
		{
			string connectionString = GetConnectionString(mongoDbWebSection, config);
			var builder = new MongoUrlBuilder(connectionString);
			builder.DatabaseName = GetDatabaseName(mongoDbWebSection, connectionString, config);

			return builder.ToString();
		}
Exemplo n.º 2
0
        /// <summary>
        /// Gets the name of the database.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="config">The config.</param>
        /// <returns></returns>
        internal static string GetDatabaseName(MongoDbWebSection mongoDbWebSection, string connectionString, NameValueCollection config)
        {
            MongoUrl mongoUrl = MongoUrl.Create(connectionString);
            if (!string.IsNullOrEmpty(mongoUrl.DatabaseName))
                return mongoUrl.DatabaseName;

            return (mongoDbWebSection != null)
                ? mongoDbWebSection.DatabaseName
                : config["database"] ?? "ASPNETDB";
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the configured connection string.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <returns></returns>
		internal static string GetConnectionString(MongoDbWebSection mongoDbWebSection, NameValueCollection config)
        {
            string connectionString = config["connectionString"];
			if (! string.IsNullOrWhiteSpace(connectionString))
				return connectionString;

            string appSettingsKey = config["connectionStringKey"];
			if (string.IsNullOrWhiteSpace(appSettingsKey))
				return (mongoDbWebSection != null) ? mongoDbWebSection.ConnectionString : "mongodb://localhost";
			else
				return ConfigurationManager.ConnectionStrings[appSettingsKey].ConnectionString;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the name of the database.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <returns></returns>
        internal static string GetDatabaseName(MongoDbWebSection mongoDbWebSection, NameValueCollection config)
		{
			return GetDatabaseName(mongoDbWebSection,
				GetConnectionString(mongoDbWebSection, config),
				config);
        }