Apache.NMS.Util.URISupport.ExtractProperties C# (CSharp) Method

ExtractProperties() public static method

public static ExtractProperties ( StringDictionary props, string prefix ) : StringDictionary
props System.Collections.Specialized.StringDictionary
prefix string
return System.Collections.Specialized.StringDictionary
        public static StringDictionary ExtractProperties(StringDictionary props, string prefix)
        {
            if(props == null)
            {
                throw new Exception("Properties Object was null");
            }

            StringDictionary result = new StringDictionary();
            List<String> matches = new List<String>();

            foreach(string key in props.Keys)
            {
                if(key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
                {
                    String value = props[key];
                    result[key] = value;
                    matches.Add(key);
                }
            }

            foreach(string match in matches)
            {
                props.Remove(match);
            }

            return result;
        }