~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/ServiceStack/src/ServiceStack.Common/ServiceClient.Web/DictionaryExtensions.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if !SILVERLIGHT && !MONOTOUCH && !XBOX
 
2
 
 
3
using System.Collections.Generic;
 
4
using System.Collections.Specialized;
 
5
 
 
6
namespace ServiceStack.ServiceModel.Extensions
 
7
{
 
8
    public static class DictionaryExtensions
 
9
    {
 
10
        public static Dictionary<string, string> ToDictionary(this NameValueCollection nameValues)
 
11
        {
 
12
            var map = new Dictionary<string, string>();
 
13
            foreach (var key in nameValues.AllKeys)
 
14
            {
 
15
                if (key == null)
 
16
                {
 
17
                    //occurs when no value is specified, e.g. 'path/to/page?debug'
 
18
                    //throw new ArgumentNullException("key", "nameValues: " + nameValues);
 
19
                    continue;
 
20
                }
 
21
 
 
22
                var values = nameValues.GetValues(key);
 
23
                if (values != null && values.Length > 0)
 
24
                {
 
25
                    map[key] = values[0];
 
26
                }
 
27
            }
 
28
            return map;
 
29
        }               
 
30
    }
 
31
 
 
32
}
 
33
#endif
 
 
b'\\ No newline at end of file'