/// <summary> /// Adds the given <see cref="Scheme"/> instance to the extent set. If /// the <see cref="Scheme"/> has the same URI as an existing entry then /// it will replace the old definition. /// </summary> /// <param name="scheme">The <see cref="Scheme"/> instance to be added.</param> /// <returns>A reference to the old <see cref="Scheme"/> object replaced /// by this action, <c>null</c> otherwise.</returns> public Scheme Add(Scheme scheme) { Scheme resultA = schemes.ContainsKey (scheme.Uri) ? schemes [scheme.Uri] : null; Scheme resultB = null; if (scheme.CanonicalUri != null) { resultB = schemes.ContainsKey (scheme.CanonicalUri) ? schemes [scheme.CanonicalUri] : null; schemes [scheme.CanonicalUri] = scheme; } schemes [scheme.Uri] = scheme; return ((resultA != null) ? resultA : resultB); }
/// <summary> /// Removes the indicated <see cref="Scheme"/> instance from the extent /// set. /// </summary> /// <param name="scheme">The <see cref="Scheme"/> to be removed.</param> /// <returns>A reference to the <see cref="Scheme"/> if it was in the /// extent set, <c>null</c> if it was not.</returns> public Scheme Remove(Scheme scheme) { Scheme resultA = null; Scheme resultB = null; if (schemes.ContainsKey (scheme.Uri)) schemes.Remove ((resultA = scheme).Uri); if (scheme.CanonicalUri != null) if (schemes.ContainsKey (scheme.CanonicalUri)) schemes.Remove ((resultB = scheme).CanonicalUri); return ((resultA != null) ? resultA : resultB); }