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;
}