I m overriding the default asp.net Membership provider and making it a singleton class? Is it the right situation to implement singleton?
public sealed class MyMembershipProvider:MembershipProvider
{
static MyMembe开发者_StackOverflow中文版rshipProvider:MembershipProviderinstance=null;
static readonly object padlock = new object();
MyMembershipProvider:MembershipProvider()
{
}
public static MyMembershipProvider:MembershipProviderInstance
{
get
{
lock (padlock)
{
if (instance==null)
{
instance = new SageFrameMembershipProvider();
}
return instance;
}
}
The Membership in fact implements the Singleton pattern and the membership provider acts as an access layer and factory for membershipuser objects. As part of customization you have to choose your custom membership provider.
精彩评论