Right now I'm having an issue with a Singleton that I just wrote for use in ASP.NET MVC -- My Singleton looks like this:
public sealed class RequestGenerator : IRequestGenerator
{
// Singleton pattern
private RequestGenerator()
{
requestList = new Stack<Request>();
appSettings = new WebAppSettings();
}
...
I've been doing some playing around with POCO objects and EntityFramework. Because of this I have to write my own Context and Repository(s). I would like all repositories to use the same context instance so changes are shared between them. To facilitate this I coded my Context as a Singleton. This way instead of getting a new context and...
Hi
I have a singleton which I hold a single integer in, my score. However when I load it form the singleton in a another view it doesn't show what I want but instead sticks at a wired 6592960. Any ideas why? Something to do with how I am using @property Im thinking, what the correct way to @property an int?
Thanks.
EDIT:
Code:
Singlet...
I have the need to implement factory class in C++, but when I was thinking about that, I found one big problem that I couldn't solve, and I found out, that all factory implementation examples around are flawed in the same way. I'm probably the one who is wrong, but please tell me why.
So here is simple "typical" factory implementation, ...
I'm developing a swing based application where I'm using many FileDialogs? So I say why not to make just one FileDialog object instead all of these instances and use it in the whole project? Is this a good assumption? does this have any performance improvement?
Thanks
...
I want to store a single row in a configuration table for my application. I would like to enforce that this table can contain only one row.
What is the simplest way to enforce the single row constraint ?
...
Hi all.
Straight to the point:
I've got two singleton classes, both inheriting their singleton nature from a super-class. I initialize some properties on the first singleton, and then have the second singleton retrieve the instance of the first one. That instance, however, does not seem to be the one I initialized in the first place. So...
I want to design a class that will be like a singleton in the way that there will be a single main instance of that class, but there can also be multiple clones of the main instance. Only 1 class will be allowed to create the main instance and everybody else can create a clone. Something like this (c#):
class Singleton
{
private st...
I have a bit of code that I've been trying to examine for thread safety. I'm using the basic lazy singleton model found here. I was wondering if it is still thread safe if I'm putting the instance in the HttpApplicationState object. I need to access this instance across all instances of the web application, so if this is not thread sa...
I'd like to know what's the best way (read most elegant) to have a single instance of a given Window per application in WPF.
I'm a newcomer to .NET and WPF and what I came up with looks pretty lame.
private static readonly Object MUTEX = new Object();
private static AboutWindow INSTANCE;
public static AboutWindow GetOrCreate() {
l...
I must be doing something very silly, but I'm getting a ExceptionInInitializerError when I try to instantiate an object in my Singleton:
class MySingleton {
private static MySingleton instance = null;
private OtherObject obj;
// Do I instantiate obj here???
private MySingleton() {
//obj = new OtherObject();
}
// Or he...
I have a plugin which at present doesn't have any extension points (neither does it extend any other plugin). To resolve a certain issue I have to create an extension-point for this plugin and an appropriate extension somewhere else.
When doing this eclipse forced me to set singleton:=true in the Manifest file. I know the reason why t...
I am working on an iphone application and don't know what the best way to hold temporary data across views. for example i have xml on a server and i parse the data into an object so that I can hold the information. The xml has some data that i want to be displayed on one view and other data that i want to be displayed on another view. I ...
If I want to create a new object that needs certain informations like a product id or something like that but the input is bad how can I elegant manage such a case?
class Product
{
function __construct($id)
{
if(is_invalid_id($id))
{ return false; }
}
}
If I initialize it this way I still get an object (since retur...
So I'm still kind of new to Objective-C, and this was my first app that I'm now updating. The idea is this: The whole app is basically various lists of stuff. It asks the API for 15 posts, shows those with a Load More button. Click Load More, it loads 15 more, etc. The API that it loads these from has a token system with a timeout built ...
I have a main class which renders tabwidget (tabhost) as follows:
intent = new Intent().setClass(this, Articles.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("articles").setIndicator("Articles",
res.getDrawable(R.drawable.ic_tab_articles))
.setCo...
I know there are lot of ways to implement a thread safe singleton pattern like (Double Check Locking , static readonly method, lock method) but i just tried below code
static void Main(string[] args)
{
for (int i = 0; i <= 100; i++)
{
Thread t = new Thread(new ParameterizedThreadStart(doSome));
t.Star...
All of a sudden I'm having a bit of an OO crisis. Over the last couple of years I've made quite good use of Singleton objects. I used them in many places.
For example, in designing an MVC Java application, I'd create a Singleton 'SystemRegistry' class to store the model and view classes (I've only worked on simple apps and the need for ...