I have a singleton which once hit will load user profile information, I want to make it an application level resource in my SL3 application so that elements across the application can bind to it.
My code version of the instantiaion is a simple
UserProfile x = UserProfile.GetInstance();
I want to be able to do this in xaml in the app...
I have a standalone singleton which successfully passes the test. But with a group of tests this fails since once a singleton is defined it does not allow to reset the instance.
Any ideas about how to go about this?
...
Is it thread safe to make Converter a singleton?
public interface IConverter<TFoo, TBar>
where TFoo : class, new()
where TBar : class, new()
{
TFoo ToFoo(TBar q);
TBar ToBar(TFoo q);
}
public class Converter : IConverter<Foo, Bar>
{
public Foo ToFoo(Bar b) {return new Foo(b);}
public Bar ToBar(Foo f) {return new...
I've created my own Delegate for a ObjC class. The class itself deals with Core Data operations. Delegate methods are used to inform other classes about changes that happened to the datastore. The class that deals with the datastore is called Datastore and it's delegate is called DatastoreDelegate. A UIViewController of mine (ContactsVie...
I have a bunch of C++ classes.
I want each class to have something like:
static int unique_id;
All instances of a same class should have the same unique_id; different classes should have different unique_id's.
The simplest way to do this appears to be threading a singleton through the classes.
However, I don't know what's called w...
In a web app, I need to have only one instance of a class called ProcessManager. One way is to make it a singleton. The other way is to use the HttpApplicationState to make sure I always access the same instance, like this:
public static ProcessManager ProcessManager
{
get
{
HttpApplica...
In our system one client may have multiple operators. However there is a "wish" from client.
One company has an account, however there can be mulitple operators assigned to this company. Client wants us to prepare a solution that only one operator from company can log in to the system at same time. How can I achieve this?
...
If my WCF Service has this attribute:
[ServiceBehavior(
InstanceContextMode = InstanceContextMode.Single,
ConcurrencyMode = ConcurrencyMode.Multiple)]
How can the following a Singleton work in a call?
System.ServiceModel.Web.WebOperationContext.Current
...
I'm working on an application with a shared object that is accessed via a singleton. It's working fine on 32-bit however on 64-bit it doesn't appear to be locking properly. In the constructor for my object I have code that checks for some config reg keys and prompts the user if they don't exist. On 32 bit I see the prompt only once as ex...
This is vexing me in my utility app: I have a singleton declared in the manner specified here: http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html
My singleton has 4 declared properties: 3 floats and an int. Now, in my view controller I set the properties like this in an updateSingleton method:
[[Singleton share...
Which one synchronization method to use to ensure a singleton remains a singleton?
+(Foo*)sharedInstance
{
@synchronized(self)
{
if (nil == _sharedInstance)
{
_sharedInstance = [[Foo alloc] init];
...
}
}
return _sharedInstance;
}
or using a mutex?
#import <pthread.h>
static pthread_mu...
Let's say I have 2 singletons, allocated on the heap, for which no delete is ever called. Let's call them A and B. Is there any way to make sure B will be the first one to be destroyed?
I'm assuming the platform may matter on this one: Visual Studio 2005 Professional, Visual C++. Everything was built with cl.
...
I have a singleton factory and would like it to return a reference to the object instance so that I can use the singleton factory to destroy the instance and not have instances elsewhere in my code to survive.
Example of what I would like to be able to do:
$cat = CatFactory::getInstance();
$cat->talk(); //echos 'meow'
CatFactory::destr...
Hi all!
I am using Apple's MyGizmoClass Singleton class for program-wide "session variables" and loving it! However, when I run "Build and Analyze" it gives weird results. Maybe my usage is wrong (it works, but it may be working due to a flakey side effect). Here is an example.
- (NSInteger)tableView:(UITableView *)tableView numberO...
Hi,
i'm developing a simple simulation with OpenGL and this simulation has some global constants that are changed by the user during the simulation execution. I would like to know if the Singleton design pattern is the best way to work as a temporary, execution time, "configuration repository"
...
In our SharePoint/ASP.NET environment we have a series of data retriever classes that all derive from a common interface. I was assigned the task of creating a data retriever that could communicate remotely with other SharePoint farms using WCF. The way I have it implemented at the moment is a singleton ChannelFactory<T> is created in a ...
if we use singleton pattern in our web application, when free the specified memory that allocated to our class?
...
I've created a singleton which in the constructor goes like this:
public static class MyCertificate
{
private readonly static X509Certificate2 _singletonInstance = new X509Certificate2();
static MyCertificate()
{
if(_singletonInstance == null)
_singletonInstance = GetMyCertificateFromDatabase();
}
...
I'm making a very simple website in Django. On one of the pages there is a vertical ticker box. I need to give the client a way to edit the contents of the ticker box as an HTMLField.
The first way that came to mind was to make a model Ticker which will have only one instance. Then I thought, instead of making sure manually that only on...
I have
class Foo
class Bar
Now, I want
Foo* Foo::singleton = new Foo();
Bar* Bar::singleton = new Bar();
to both initialize before
int main()
is called.
Furthermore, I want
Foo::singleton
to initialize before
Bar::singleton
Is there anyway I can ensure that?
Thanks!
...