using Spring.Objects.Factory.Config; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Reflection; using Sleis.Infrastructure; namespace Sleis.Utility { public interface IPropertyPlaceholder { IDictionary ExposedProps { get; } string Get(string key); } public class PropertyUtility : PropertyPlaceholderConfigurer, IPropertyPlaceholder { private IDictionary _exposedProperties = new Dictionary(); public PropertyUtility() : base() { this.IgnoreResourceNotFound = false; this.IgnoreUnresolvablePlaceholders = false; this.EnvironmentVariableMode = EnvironmentVariableMode.Fallback; } protected override void ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props) { base.ProcessProperties(factory, props); for (int i = 0; i < props.Count; ++i) { _exposedProperties.Add(props.GetKey(i), props.Get(i)); } } public IDictionary ExposedProps { get { return _exposedProperties; } } public string Get(string key) { if (_exposedProperties.ContainsKey(key)) { return _exposedProperties[key]; } else { return String.Empty; } } } }