コード例 #1
0
        /// <summary>
        /// Resolve the given placeholder using the given name value collection,
        /// performing an environment variables check according to the given mode.
        /// </summary>
        /// <remarks>
        /// <p>
        /// The default implementation delegates to
        /// <see cref="ResolvePlaceholder(string, NameValueCollection)"/>
        /// before/afer the environment variable check. Subclasses can override
        /// this for custom resolution strategies, including customized points
        /// for the environment properties check.
        /// </p>
        /// </remarks>
        /// <param name="placeholder">The placeholder to resolve</param>
        /// <param name="props">
        /// The merged name value collection of this configurer.
        /// </param>
        /// <param name="mode">The environment variable mode.</param>
        /// <returns>
        /// The resolved value or <see langword="null"/> if none.
        /// </returns>
        /// <seelso cref="Spring.Objects.Factory.Config.EnvironmentVariableMode"/>
        protected virtual string ResolvePlaceholder(string placeholder,
                                                    NameValueCollection props,
                                                    EnvironmentVariableMode mode)
        {
            string propertyValue = null;

            if (mode == Spring.Objects.Factory.Config.EnvironmentVariableMode.Override)
            {
                propertyValue = Environment.GetEnvironmentVariable(placeholder);
            }
            if (propertyValue == null)
            {
                propertyValue = ResolvePlaceholder(placeholder, props);
            }
            if (propertyValue == null &&
                mode == Spring.Objects.Factory.Config.EnvironmentVariableMode.Fallback)
            {
                propertyValue = Environment.GetEnvironmentVariable(placeholder);
            }
            return(propertyValue);
        }
		/// <summary>
		/// Resolve the given placeholder using the given name value collection,
		/// performing an environment variables check according to the given mode.
		/// </summary>
		/// <remarks>
		/// <p>
		/// The default implementation delegates to 
		/// <see cref="ResolvePlaceholder(string, NameValueCollection)"/>
		/// before/afer the environment variable check. Subclasses can override
		/// this for custom resolution strategies, including customized points
		/// for the environment properties check.
		/// </p>
		/// </remarks>
		/// <param name="placeholder">The placeholder to resolve</param>
		/// <param name="props">
		/// The merged name value collection of this configurer.
		/// </param>
		/// <param name="mode">The environment variable mode.</param>
		/// <returns>
		/// The resolved value or <see langword="null"/> if none.
		/// </returns>
		/// <seelso cref="Spring.Objects.Factory.Config.EnvironmentVariableMode"/>
		protected virtual string ResolvePlaceholder(string placeholder,
		                                            NameValueCollection props,
		                                            EnvironmentVariableMode mode)
		{
			string propertyValue = null;
			if (mode == Spring.Objects.Factory.Config.EnvironmentVariableMode.Override)
			{
				propertyValue = Environment.GetEnvironmentVariable(placeholder);
			}
			if (propertyValue == null)
			{
				propertyValue = ResolvePlaceholder(placeholder, props);
			}
			if (propertyValue == null
				&& mode == Spring.Objects.Factory.Config.EnvironmentVariableMode.Fallback)
			{
				propertyValue = Environment.GetEnvironmentVariable(placeholder);
			}
			return propertyValue;
		}