Seems to me like you are looking for a depedecy injection framework like
windsor from the castle project.

Cheers,

Greg

On 7/9/07, Ron Young <[EMAIL PROTECTED]> wrote:
Further reference:

DownloadManager : BaseMangager<IDownloadManager>
{
}

Problem is that the concept of "manager" should be allowed to work with many
different providers. Like another provider might be an "audit provider", or
a "calculate charge per request" provider.

Our architecture is the stage above, and I think it needs to go to the stage
described - drop generics and go with encapsulation or composition.

rpn

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ron Young
Sent: Monday, July 09, 2007 1:55 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] C# Singleton; foot in mouth

Yes, thanks.

But is it a singleton.

internal abstract class BaseManager<I> where I: IEntityProvider
{
       private static I _provider = default(I);
       private static object _syncLock = new object();

       protected static I Provider
       {
               if (_provider == null)
               {
                       lock (_syncLock)
                       {
                               if (provder = null)
                                       provider =
Activator.createfromconfig(...);
                       }
               }
               return _provider;
}

Pardon the syntax.

Client side code is getting really strange, I don't like it and guess I
better say something.

But, that is a double-check lock, and I would need to document that at least
the BaseManager.Provider property is thread safe.

Ron
-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Greg Young
Sent: Monday, July 09, 2007 12:53 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] C# Singleton; foot in mouth

Ron see previous comments in your other post about gaurentees in ECMA
335 about cctor execution. It fits wonderfully with the sigleton
pattern as the type initializer is only run once and will be before
any method is called (on a reference type).



On 7/9/07, Ron Young <[EMAIL PROTECTED]> wrote:
> I just read this... http://www.yoda.arachsys.com/csharp/singleton.html
> Third version
>
> Wow, that looks like double check lock and he says its bad.
>
> This sucks. I thought that was a pattern.
>
> Ron
> -----Original Message-----
> From: Discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] On Behalf Of Miika Mäkinen
> Sent: Monday, July 09, 2007 12:23 AM
> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
> Subject: [ADVANCED-DOTNET] C# Singleton
>
> Hi guys,
> Which singleton implementation do you normally use? I've been using number
> five from http://www.yoda.arachsys.com/csharp/singleton.html but reading
> http://msdn2.microsoft.com/en-us/library/ms954629.aspx I'm understanding
> that a simpler implementation works just the same?
>
> Cheers,
> Miika
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>


--
Studying for the Turing test

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



--
Studying for the Turing test

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to