开发者

using singleton pattern in custom membership provider class

开发者 https://www.devze.com 2023-03-07 04:28 出处:网络
I m overriding the default asp.net Membership provider and making it a singleton class? Is it the right situation to implement singleton?

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

精彩评论

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