object

VB.NET - Alias to class' properties

I have an object and I iterate over object's properties. Foreach property, i append it as a column to a listview. In my object, some properties doesn't have accents. But in portuguese, they do. For example: "Endereco" property must be "Endereço". I need an away to create an alias to the properties. Is it possible in VB.NET? Thank you. ...

PHP : Remove object from array

What is an elegant way to remove an object from an array of objects in PHP ? Just to be clear .. class Data{ private $arrObservers; public add(Observer $o) { array_push($this->arrObservers,$o); } public remove($Observer $o) { // I NEED THIS CODE to remove the object } } ...

Quicktime Playback using Javascript

I have been reading the JavaScript Scripting Guide for Quicktime and in there it gives you an example on how to play a video using a javascript command. Unfortunately whenever I try, I am given the error document.Camera_0.Play() is not a function in firebug. My code is as follows: QT_WriteOBJECT_XHTML( 'video_place...

Creating an object with dynamic properties in C#

Hi, I'm using linq to load a csv file, but because the csv may have any number of columns, the object that it returns will need dynamic properties, and I can't figure out how to do that. var data = from row in csvData let col = row.Split(',') select new { Field1 = data[0], ...

Mocking scala object

I am using mockito and trying to mock a scala object. object Sample { } //test class SomeTest extends Specification with ScalaTest with Mockito { "mocking should succeed" in { val mockedSample = mock[Sample] } } Give me 2 compilation errors. error: Not found type Sample error: could not find implicit value for parameter...

Unexplainable "can't modify frozen object" exception

Hey, I have encountered a weird problem twice in the past 2 weeks and it's starting to piss me off. I have this very simple code : Rails.logger.debug "Is current_step frozen ? => #{@current_step.frozen?.inspect}" @current_step += 1 Has you can (or not) imagine, this is what is displayed on my console : Is current_step frozen ...

Handle HTML code block as an object ?

Hi ! I have a div that basically represents a book (so a nice div layout with an image of the book, title, price, red background if on sale etc.). So what i do is to get the properties of a book from the database, insert the values in kind of an html template and display it. Now, once it is displayed i hate how i have to handle the da...

What's the right technique for accessing an object's data in JavaScript?

I have this object: var count = { table: 15, people: 34, places_details: 85, story_1: 21, story_2: 6, story_3: 11, } This array: var categories = ['table', 'people', 'places_details', 'story_1', 'story_2', 'story_3'] And this function: function preloadThumbs() { var j=0; for (j=0; j<categories.length; j++) { var k=1; ...

Strange problem with reference and object cloning

Hi I have a strange problem with reference and object cloning, which I'm not able to solve. I have a class MyClass which consist of property Name. I also have my custon user control, which have a property of type MyClass - myclassproperty. These controls are placed on form. If I click one of control a new form apperas. I pass one argume...

Accessing this from within an object's inline function

I'm having difficulty referencing "this" from within a javascript inline function, within an object method. var testObject = { oThis : this, testVariable : "somestring", init : function(){ console.log(this.testVariable); // outputs testVariable as expected this.testObject.submit(function(){ var a...

When fine tuning performance, what is the best way to call Javascript methods multiple times?

Hello, I have been researching Javascript performance. I've learned that when accessing more than once, it is usually best to copy closure variables and class members into local scope to speed things up. For example: var i = 100; var doSomething = function () { var localI = i; // do something with localI a bunch of times v...

PHP object default return value

I have a function which returns object array like that: <?php function sth() { return (object) array( "obj1" => $obj1, "obj2" => $obj2, "obj3" => $obj3 ); } $obj = sth(); echo $obj; ?> Here I want to define $obj's default value.It will return default value instead of $obj1,$obj2,$obj3. How can I define a defa...

event driven simulation with objects

hi everyone, i am writing an event driven simulation program. i have 3 subclasses that inherit 1 base class. i need to generate those three randomly and each subclass will go through different event path (sorry its a bit hard to describe what i meant), ill give an example: let say we have a car park simulation at a mall, we have the ba...

Is it possible to delete an object's property in PHP?

Hi there, If i have an stdObject say, $a. Sure there's no problem to assign a new property, $a, $a->new_property = $xyz; But then I want to remove it, so unset is of no help here. So, $a->new_property = null; Is kind of it. But is there a more 'elegant' way? Thanks in advance. ...

How do I make a member of a class a hash in Perl?

I am trying to write a package in perl. I need one of the members to be a hash. However, when I reference and run the program, I cannot get it to work with the usual syntax. If I have: sub new { my $class = shift; my $self = { textfile => shift, placeholders => () }; bless $self, $class; return $self; } Is there any way of mak...

How can I get name of an object in Perl?

Say I make an object as follows: $object22=new somepackage("stuff"); and later I want to run a subroutine like this: $object22->somesubroutine(); I would like to capture the string "object22" in the subroutine "somesubroutine." I tried: $self=@_; print $self; but that just gave me somepackage=HASH(somehexnumber) Please let me k...

How to iterate over an array of stdObject elements in PHP?

This is the print_r() version of a data structure that I need to access via a foreach loop: stdClass Object ( [DetailedResponse] => Array ( [0] => stdClass Object ( ... ) [1] => stdClass Object ( ... Now, how do I iterate though these objects? I can...

Object of class stdClass could not be converted to string

I am having a problem with PHP at the moment, I am getting this error, Object of class stdClass could not be converted to string the error occurs when I run this portion of code in my site, function myaccount() { $data['user_data'] = $this->auth->get_userdata($this->uri->segment(3)); //var_dump($data['user_data']); $this-...

Are add() and appendChild() the same for select DOM objects?

Hello! I'm working on a small web application that changes the contents of a select drop-down. I was wondering if appendChild() and add() both accomplish the same task on a select DOM object in JavaScript? var someSelect = document.getElementById('select-list'); var newOption = document.createElement('option'); someSelect.appendChild...

How to make a hash of objects in perl

I would like to be able to store objects in a hash structure so I can work with the name of the object as a variable. Could someone help me make a sub new{ ... } routine that creates a new object as member of a hash? I am not exactly sure how to go about doing this or how to refer to and/or use the object when it is stored like this. I ...