Rafael_Cardero

Hi

Does somebody can tell me how can I implement the pluggable factory design pattern in C#

The problem resides on C# does not initialize static fields at program startup, like C++
C# initializes static fields before the first call to a type-member.

Thanks




Re: Visual C# General Implementing the Pluggable Factory Design Pattern en C#

OmegaMan

I am not sure what static fields has to do with it...but I created a plug-in interface by having the program check for dlls in the target directory. It then queried them for a specific interface and then loaded that interface via reflection. Check out my post Reflection: Best way to identify if a specific Interface Exists on my ups and downs in querying for the interface.





Re: Visual C# General Implementing the Pluggable Factory Design Pattern en C#

Managed Snake

If your problem is just to intialize static fields, then use a static constructor, http://msdn2.microsoft.com/en-us/library/k9x6w0hc(VS.80).aspx

Good luck





Re: Visual C# General Implementing the Pluggable Factory Design Pattern en C#

timvw

You could always the System.Runtime.CompilerServices.RuntimeHelpers and it's RunClassConstructor method to initialize the type...