Files
Umbraco-CMS/src/Umbraco.Core/NameValueCollectionExtensions.cs
Shannon e0e5aef43e Fixes lots of membership provider stuff
U4-3057 MembershipPasswordFormat problem at EncodePassword method in UmbracoMembershipProvider class
U4-3176 UsersMembershipProvider.CreateUser does not encrypt/hash the password
U4-3173 UserMembershipProvider.ChangePassword does not work
2013-10-17 17:40:29 +11:00

36 lines
933 B
C#

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
namespace Umbraco.Core
{
internal static class NameValueCollectionExtensions
{
public static bool ContainsKey(this NameValueCollection collection, string key)
{
return collection.Keys.Cast<object>().Any(k => (string) k == key);
}
public static T GetValue<T>(this NameValueCollection collection, string key, T defaultIfNotFound)
{
if (collection.ContainsKey(key) == false)
{
return defaultIfNotFound;
}
var val = collection[key];
if (val == null)
{
return defaultIfNotFound;
}
var result = val.TryConvertTo<T>();
return result.Success ? result.Result : defaultIfNotFound;
}
}
}