• Code
  • Tags
  • Users
  • Titles
  • Log in
  • Feedback
  • FAQ
Share Code
Welcome to ForkCan.com

ForkCan is all about sharing code in a social way.

Discuss, debate or argue with other devs about their or your own code.

Give other devs feedback or make a Fork (Make a better version of a shared code).

Rate the code, if you use the code mark it as used so others can see if the shared code is used by someone.

Help each other to be better devs and to be more productive.


Features not working yet:

Flag a post


QR Code

Tiny Url

http://4kcan.com/s/MTc0

Related Code
PagedList class and paging code for ASP.Net MVC (Nothing new but kind of usefull.)
Fork of GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6
WCF Service factory for using Microsoft Unity 2.0 to create an instance of a Service
Unity Controller Factory for ASP.NET MVC 3.0
WCF RIA Services Unity 2.0 DomainService Factory
ActionFilter to Handle and Log Error for each Controller, ASP.NET MVC
Get Cookies in Web Api Asp .net Mvc 4 RC
GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6
Simple light ObjectFactory using Unity

HttpContextLifetimeManager for Unity

A HttpContextLifetimeManager to make Unity 2.0 work better with for example MVC.

0
1.2k 0 0 0 0 1

public class HttpContextLifetimeManager<T> : LifetimeManager, IDisposable
{
    public override object GetValue()
    {
        return HttpContext.Current.Items[typeof(T).AssemblyQualifiedName];
    }

    public override void RemoveValue()
    {
        HttpContext.Current.Items.Remove(typeof(T).AssemblyQualifiedName);
    }

    public override void SetValue(object newValue)
    {
        HttpContext.Current.Items[typeof(T).AssemblyQualifiedName] = newValue;
    }

    public void Dispose()    
    {
        RemoveValue();
    }
}

Share: twitter | facebook   Action: used | fork | flag

c#

Mark 'c#' tag as 'like'

Mark 'c#' tag as 'ignore'

di

Mark 'di' tag as 'like'

Mark 'di' tag as 'ignore'

mvc

Mark 'mvc' tag as 'like'

Mark 'mvc' tag as 'ignore'

unity

Mark 'unity' tag as 'like'

Mark 'unity' tag as 'ignore'


 @abratland "No. 1"
109
July 12, 2010 9:27 AM

Fork

 HttpContextLifetimeManager for Unity -  @abratland Monday 12, 2010 9:27 AM


0 Feedback


You must log in before you can give any feedback


1 Discussion(s)

Newest Oldest
0

Regarding the "generic of T" stuff to get a key - I haven't seen that specific pattern before, what's the reasoning behind it?

Also, couldn't you make typeof(T).AssemblyQualifiedName a static variable instead of re-evaluating it in every call?

link | flag  | Reply

 @CodingInsomnia "First one to share code"
349
Monday 12, 2010 11:09 AM


You must log in before you can post a comment

Squeed
Made by: Fredrik Normén 2010