/// <summary> /// Adds a <see cref="Value"/> instance to the extent set manange by /// this instance. If the new value has the same code as an existing /// entry it will replace it and a reference to the old instance will /// be returned to the caller. /// </summary> /// <param name="value">The scheme <see cref="Value"/> to be added.</param> /// <returns>The old <see cref="Value"/> instance having the same code /// as the new one, otherwise <c>null</c>.</returns> protected internal Value Add(Value value) { Value result = values.ContainsKey (value.Code) ? values [value.Code] : null; values [value.Code] = value; return (result); }
/// <summary> /// Finds the subset of scheme values that match the provided regular /// expression. No particular ordering of the values is enforced. /// </summary> /// <param name="pattern">A regular expression.</param> /// <returns>An array containing the matching <see cref="Value"/> instances.</returns> public Value[] Like(string pattern) { ArrayList matches = new ArrayList (); Regex regex = new Regex (pattern); Value [] result; foreach (Value value in values.Values) if (regex.IsMatch (value.Code)) matches.Add (value); result = new Value [matches.Count]; matches.CopyTo (result, 0); return (result); }