开发者

using singleton pattern in custom membership provider class

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜