instance

Creating many new instances vs reusing them?

I have multiple business entities in VB.NET Windows Forms application. Right now they are instanced on application startup and used when needed. They hold descriptions of business entities and methods for storing and retrieving data. To cut the long story short, they are somewhat heavy objects to construct (they have some internal dictio...

Use an instance of an object throughout the site with PHP

Hello Guys, How will I use an instance of an object that is initially loaded throughout the whole site? I want $myinstance to be used everywhere. $myinstance = new TestClass(); Thanks! ...

How to extend methods to a class not to its instances.

Hi. Extending methods to any instance is really easy: public static string LeaveJustNumbers(this string text) { return Regex.Replace(text, @"[\D]", ""); } ... string JustNumbers = "A5gfb343j4".LeaveJustNumber(); But what if i want to extend methods to a sealed class like string, to work like: string.Format("Hi:{0}","Fraga"); I...

Why is this class re-initialized every time?

I have 4 files and the code 'works' as expected. I try to clean everything up, place code into functions, etc... and everything looks fine... and it doesn't work. Can somebody please explain why MatLab is so quirky... or am I just stupid? Normally, I type terminator = simulation(100,20,0,0,0,1); terminator.animate(); and it shou...

Changing Graphic Instance using ActionScript

Hi, I was wondering if it is at all possible to change the "Graphic" used in a frame dynamically using actionscript. I was hoping to either change the image the Graphic is an instance of or change the Graphic I am using in the current frame. Cheers Addition: Could I have a layer for each Graphic and then using action script choose wh...

RegexKitLite & Unrecognized Selector Sent to Instance Error..

Hi Guys, I am not sure why the following line: addDetails.Address = [addDetails.Address stringByReplacingOccurrencesOfRegex:@" +" withString:@" "]; causes an "Unrecognized Selector Sent to Instance" error, closing my iPhone App in my Simulator(XCode). What's wrong with my code? ...

Create multiple instances of custom Powershell object

I am creating a new object in a Powershell script, or actually an object type. I want to create multiple instances of this object. How do I do this? The code below is what I am working on, it appears that all instances in the array reference the same object, containing the same values. # Define output object $projectType = new-object ...

An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.

I get this error when attempting to debug my form, I cannot see where at all the error could be (also does not highlight where), anyone have any suggestions? An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Dim dateCrap As Str...

How do i get (is it possible to) a reference to the class that creates an instance of another class.

Odd situation... I need to create a new instance of a class that needs a member of the calling class. But i can't pass a reference to the calling class through the constructor. The solution i am looking for is something like this: Public Class ChildClass Public Sub New(args) _MyMember = GetMemberFromCallingClass() ....

Get Instance ID of an Object in PHP

I've learn a while ago on StackOverflow that we can get the "instance ID" of any resource, for instance: var_dump(intval(curl_init())); // int(2) var_dump(intval(finfo_open())); // int(3) var_dump(intval(curl_init())); // int(4) var_dump(intval(finfo_open())); // int(5) var_dump(intval(curl_init())); // int(6) I need something simi...

What is the difference between an Instance and an Object?

What is the difference between an Instance and an Object? Is there a difference or not? ...

Two Instances of Sql Server (2005 and 2008)

Hi All, I installed Visual Studio 2008 Professional in my machine and It had installed SQL Server Express 2005 database in machine, and I use it very fine! I installed SQL Managment Studio and works great. So, in this week I Installed Visual Studio 2010 Pro in machine and the setup installed the SQL Server express 2008 and it overwrite...

jquery ui datepicker onselect inst target

So I have what I think is a pretty basic question but I cant for the life of me figure it out. How do you reference the selected date element (dom) once clicked. I have tried this: $("#eventCalendar").datepicker({ onSelect: function(dateText,inst){ var activeDateObj = $("#eventCalendar").find('.ui-state-active'); } }); This r...

Java - How to set focus the already running application ?

I am using a ServerSocket port to run one instance only of my Java Swing application, so if a user tries to open another instance of the program, i show him a warning that "Another instance is already open". This works fine, but instead of showing this message i want to set focus on the running application itself, like some programs does...

How to load and pass a Xforms form in Orbeon (How to Send instance to XForms) ?

Hi, I am using the Orbeon Forms solution to generate messages from filled-in web forms. I read different code snippetse in Orbeon's wiki on XForms submission from a pipeline, and I tried different solutions but it doesn't work, and there is no example with a POST from a pipeline, caught by a PFC and sent to an XForms view that receives...

Rails: i have a class method and i want to modify something of the instance

Rails: i have a class method and i want to modify something of the instance something like this: class Test < Main template :box def test # here I want to access the template name, that is box end end class Main def initialize end def self.template(name) # here I have to save somehow the template name ...

Force C# Compiler to Create an Unused Object Instance

Yes exactly what I want to do :) At least for a particular class. The problem is, I create a static instance of an object but I don not use it directly. Since I do some operations in the constructor ,like adding the object to a list, the constructor must be invoked at least once before I get the list. I guess that the compiler just opti...

Is there a straightforward way to have a thread-local instance variable?

With the ThreadStatic attribute I can have a static member of a class with one instance of the object per thread. This is really handy for achieving thread safety using types of objects that don't guarantee thread-safe instance methods (e.g., System.Random). It only works for static members, though. Is there any straightforward way to d...

Add a child inside a newly created instance, inside of a loop in AS3

I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do. var xml:XML; var xmlReq:URLRequest = new URLRequest("xml.xml"); var xmlLoader:URLLoader = ...

django forms instance

hello, i have a method where i am saving the data from users, but each user has to have a single profile, so each time he saves, the data should be overwritten. first i verify if he already has a profile data, and in this case i add an instance to the form. if not, (this is his first registration), i simply add data into DB my code is: ...