2010-06-21 Marek Habersack <mhabersack@novell.com>
[mcs.git] / class / System.Web.Mvc / System.Web.Mvc / NameValueCollectionExtensions.cs
blob7faf9f09877b76ea93decf17bddf93727dcb2150
1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * This software is subject to the Microsoft Public License (Ms-PL).
6 * A copy of the license can be found in the license.htm file included
7 * in this distribution.
9 * You must not remove this notice, or any other, from this software.
11 * ***************************************************************************/
13 namespace System.Web.Mvc {
14 using System;
15 using System.Collections.Generic;
16 using System.Collections.Specialized;
18 public static class NameValueCollectionExtensions {
20 public static void CopyTo(this NameValueCollection collection, IDictionary<string, object> destination) {
21 CopyTo(collection, destination, false /* replaceEntries */);
24 public static void CopyTo(this NameValueCollection collection, IDictionary<string, object> destination, bool replaceEntries) {
25 if (collection == null) {
26 throw new ArgumentNullException("collection");
28 if (destination == null) {
29 throw new ArgumentNullException("destination");
32 foreach (string key in collection.Keys) {
33 if (replaceEntries || !destination.ContainsKey(key)) {
34 destination[key] = collection[key];