private AddPropertyDirect ( String key, Object obj ) : void | ||
key | String | key to use for mapping /// |
obj | Object | object to store /// /// |
return | void |
public virtual ExtendedProperties Subset(string prefix) { ExtendedProperties properties = new ExtendedProperties(); IEnumerator keys = this.Keys; bool flag = false; while (keys.MoveNext()) { object current = keys.Current; if ((current is string) && ((string)current).StartsWith(prefix)) { if (!flag) { flag = true; } string key = null; if (((string)current).Length == prefix.Length) { key = prefix; } else { key = ((string)current).Substring(prefix.Length + 1); } properties.AddPropertyDirect(key, this[current]); } } if (flag) { return(properties); } return(null); }
public ExtendedProperties Subset(string prefix) { ExtendedProperties extendedProperties = new ExtendedProperties(); bool flag = false; foreach (object current in this.Keys) { if (current is string && ((string)current).StartsWith(prefix)) { if (!flag) { flag = true; } string key; if (((string)current).Length == prefix.Length) { key = prefix; } else { key = ((string)current).Substring(prefix.Length + 1); } extendedProperties.AddPropertyDirect(key, this[current]); } } ExtendedProperties result; if (flag) { result = extendedProperties; } else { result = null; } return(result); }
/// <summary> Create an ExtendedProperties object that is a subset /// of this one. Take into account duplicate keys /// by using the setProperty() in ExtendedProperties. /// * /// </summary> /// <param name="prefix">prefix /// /// </param> public ExtendedProperties Subset(String prefix) { ExtendedProperties c = new ExtendedProperties(); bool validSubset = false; foreach(Object key in Keys) { if (key is String && ((String) key).StartsWith(prefix)) { if (!validSubset) validSubset = true; String newKey; /* * Check to make sure that c.subset(prefix) doesn't * blow up when there is only a single property * with the key prefix. This is not a useful * subset but it is a valid subset. */ if (((String) key).Length == prefix.Length) { newKey = prefix; } else { newKey = ((String) key).Substring(prefix.Length + 1); } /* * use addPropertyDirect() - this will plug the data as * is into the Map, but will also do the right thing * re key accounting */ c.AddPropertyDirect(newKey, this[key]); } } if (validSubset) { return c; } else { return null; } }