views:

37

answers:

2

Hi,

I'd like to expose some functionality via a WCF service. I can configure WCF to instantiate a class per-request but am unsure how I can get a reference to a communal singleton -

If I were to have some functionality to store a list of calls to a method (call it LogMethod) via WCF in memory and return that list when the GetLogs method is called

I'm aware I could use a database/the file system to pass this data back an forth but in many cases, that seems to be overkill.

Can someone explain how I can use a singleton class (I'm aware it will need to be thread-safe) ?

Many thanks

Edit: It seems that nobody has a clear answer - I can't believe this is complex. Am I missing something obvious?

A: 

Your WCF service can simply access any singleton object. For that matter you can (and I have) simply have a Shared member in your WCF service.

Larsenal
Then perhaps I'm missing something in implementing a singleton class - I would've done something like a property on object A which manages a singleton class (Object B) through the getter. The getter is called from the WCF class (Obj C, D, E, ... n). In this scenario, what is object A? I can see how a shared member may be useful but not if I have a class I need to instantiate
Basiclife
A: 

I finally found a WCF article that explains an even better way of implementing this... "Discover Mighty Instance Management Techniques For Developing WCF Apps"

Basiclife