Created
September 20, 2013 01:51
-
-
Save asoftwareguy/6632356 to your computer and use it in GitHub Desktop.
SessionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web; | |
namespace Example.Web.Utils | |
{ | |
public static class SessionExtensions | |
{ | |
public static void SetAttribute(this HttpSessionStateBase Session, string name, object value, params Func<bool>[] conditionPredicates) | |
{ | |
if (conditionPredicates != null) | |
{ | |
for (int i = 0; i < conditionPredicates.Length; i++) | |
{ | |
Func<bool> conditionPredicate = conditionPredicates[i]; | |
if (!conditionPredicate()) | |
{ | |
return; | |
} | |
} | |
} | |
Session[name] = value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment