Skip to content

Instantly share code, notes, and snippets.

@asoftwareguy
Created September 20, 2013 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asoftwareguy/6632356 to your computer and use it in GitHub Desktop.
Save asoftwareguy/6632356 to your computer and use it in GitHub Desktop.
SessionExtensions.cs
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