instance

ASP.NET: strategies to manage a single browser instance...(no new tabs/windows)

All the browsing to this particular website should happen within the instance it was logged-in from...it should not allow side-by-side browsing if opened in a new tab or a new window. In other words if I am already browsing (and logged-in), and decide to open an new tab/window to browse the same site...my server should trap this, and rep...

Getting an instance name inside class __init__()

While building a new class object in python, I want to be able to create a default value based on the instance name of the class without passing in an extra argument. How can I accomplish this? Here's the basic pseudo-code I'm trying for: class SomeObject(): defined_name = u"" def __init__(self, def_name=None): if def_n...

Same instance referred to by multiple constructors

I have an instance of Class A that I want to refer to in the constructor of multiple instances of B. How can I refer to that particular instance of Class A in each new instance of B? ...

Threading / Linq Class list problem

Ok, so ive been writing a very complex multiserver irc bot recently, and ive encountered an issue.. i stipped down the code as much as i could because its very large, the full code is here: http://pastie.org/691449.txt so what my issue is, when i call the Disconnect() void in Connection, instead of disconnecting and closing the given se...

What are SingletonMethods and InstanceMethods in Ruby

I see a lot of stuff include ActiveRecord::XXXX::InstanceMethods extend ActiveRecord::XXXX::SingletonMethods I am unaware of the property or there working, just wanted a easy to understand answer. if it has a good reason to be used. ...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes this How to do this? ...

Check if a specific exe file is running

I want to know how i can check a program in a specific location if it is running. For example there are two locations for test.exe in c:\loc1\test.exe and c:\loc2\test.exe. I only wanted to know if c:\loc1\test.exe is running and not all instances of test.exe. ...

Invoking an instance method without invoking constructor

Let's say I have the following class which I am not allowed to change: public class C { public C() { CreateSideEffects(); } public void M() { DoSomethingUseful(); } } and I have to call M without calling the constructor. Is it possible? ...

Method accessing protected property of another object of the same class

Should an object's method be able to access a protected property of another object of the same class? I'm coding in PHP, and I just discovered that an object's protected property is allowed to be accessed by a method of the same class even if not of the same object. In the example, at first, you'll get "3" in the output - as function r...

get the control with a certain name provided as a string in c#

Hi there, i have the name of a control in a string and I want to manipulate the control, how do i turn the string into the current form instance of that control in c#? e.g. string controlName = "Button1"; What goes here? button1.text = "Changed"; Thanks ...

How to dynamically create a union instance in c++?

I need to have several instances of a union as class variables, so how can I create a union instance in the heap? thank you ...

Can a C++ Class Constructor Know Its Instance Name?

Is it possible to know the object instance name / variable name from within a class method? For example: #include <iostream> using namespace std; class Foo { public: void Print(); }; void Foo::Print() { // what should be ????????? below ? // cout << "Instance name = " << ?????????; } int main() { Foo a, ...

How do I delete an instance of an intermediate model in a Django Many-to-many relationship?

According to an example at http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships I have three models: class User(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(User, through...

c++: Object's variable cannot be evaluated, but variable from reference to the same object can???

Ok, this is veeery weird... I think. What I mean with the title is: inside the act() function from an actionHandler object I have: state->getHumanPieces(); Which gives me an address violation of some sort, apparently 'this' does not have a 'state' variable initialized... It so happens this actionHandler class has a static variable, w...

How to get instance ID with PHP

I'm looking for a way to get the instance ID of a given object / resource with PHP, the same way var_dump() does: var_dump(curl_init()); // resource #1 of type curl var_dump(curl_init()); // resource #2 of type curl How can I get the instance count without calling var_dump()? Is it possible? ...

How to use the Facade.Instance method without object construction?

I only recently completed a unit on software patterns and am now attempting to comprehend the PureMVC framework. One thing has got my stumped however, something which is simple to the gurus here. I'm attempting to create an instance of the singleton Facade class. In the constructor, the comments state: This IFacade implementation is...

How to avoid multiple instances of a program?

I need to find a right way to prevent two running instances of my (Python) program. I am currently using the following method. On Windows, os.popen('wmic process get caption,processid | findstr `programname.exe`') On Linux, os.popen('ps x | grep `programname`') It seems to work fine for now. Is this method correct? Can someone sug...

ActionScript 3 - Static Versus Instance Methods

Hi guys, I'm working on a video player and I initially developed the player with everything in the .FLA file with no classes. Then I started modularizing my player into classes and realised that my classes are static methods rather than instance methods which doesn't seem to be needed in my player. My question is - is this a bad design ...

Getting the .NET Class associated with a process

As part of a WMI Coupled provider that I'm creating I need to write an instance enumerator. The code I have is below. What I need to do is get the Class instance associated with the process. Any ideas? static public WMIProviderSample GetInstance([ManagementName("ID")] int processId) { try { Process[] ...

VB.NET Single object instance only

VB.NET: What is the best way to ensure that a particular object may be instantiated only once during program execution? ...