Showing posts with label base. Show all posts
Showing posts with label base. Show all posts

Monday, March 26, 2012

public override void Dispose() throws error after loaded

in Extender Control Base I have this code

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design","CA1063:ImplementIDisposableCorrectly", Justification ="Using correct base class implementation and simply setting a flag on the way")]public override void Dispose() {this._isDisposed =true;base.Dispose(); }

After this runs I get an error in ScriptResource.axd

if (typeof(browserHandler) !=='function')throw Error.invalidOperation(Sys.Res.eventHandlerInvalid);
I am using IE 7
[Behaviors: This method releases all unmanaged resources held by the current instance. When theexplicitDisposing parameter istrue, this method releases all resources held by any managed objects referenced by the current instance. This method invokes theDispose() method of each referenced object.]

[Overrides: Override this method to dispose of resources allocated by types derived from WaitHandle. When overridingDispose(Boolean), be careful not to reference objects that have been previously disposed in an earlier call toDispose orClose .Dispose can be called multiple times by other objects. ]

[Usage: This method is called by the publicSystem.Threading.WaitHandle.Dispose(System.Boolean) method and theSystem.Object.Finalize method.Dispose() invokes this method with theexplicitDisposing parameter set totrue. System.Object.Finalize invokesDispose withexplicitDisposing set tofalse .]

Take a look at

http://www.codeproject.com/useritems/idisposable.asp

for examplees


I'll take a look at that link. thanks.

Saturday, March 24, 2012

Question about Overriding Methods

Greetings,
I'm having trouble seeing the base class method if I've overriden it...I am not sure what I'm doing wrong. I've tried to study how the Atlas framework is using it, but nothing is working. Here's my code:
Type.registerNamespace("Juicy.Collections");
Juicy.Collections.ArrayList = function() {
var _items = new Array();
this.get_item = function(i) { return _itemsIdea [I]; }
this.get_length = function() { return _items.length; }
this.add = function(item) { _items.add(item); }
this.clear = function() { _items.clear(); }
this.dispose = function() { for (var i = 0; i < _items.length; i++) { _itemsIdea [I].dispose(); _itemsIdea [I] = null; } _items.clear(); }
}
Type.registerClass("Juicy.Collections.ArrayList", null, Web.IDisposable);
Type.registerNamespace("Juicy.UI");
Juicy.UI.TabPageCollection = function(owner) {
Juicy.UI.TabPageCollection.initializeBase(this);
var _owner = owner;
this.add = function(tabPage) { Juicy.UI.TabPageCollection.callBaseMethod(this, "add", tabPage); } // The callBaseMethod always evaluates to null.
Juicy.UI.TabPageCollection.registerBaseMethod(this, "add"); }
Type.registerClass("Juicy.UI.TabPageCollection", Juicy.Collections.ArrayList);
// Code to test the above. The get_length() works fine, but the add does not increment properly.
var tabPages = new Juicy.UI.TabPageCollection();
tabPages.add("foo");
alert(tabPages.get_length());
I want the "add" method in TabPageCollection to do some work, and then call the inherited add. But the callBaseMethod does not resolve.
Any ideas anyone? This is driving me nuts here.
Thanks,
William

I think I found the answer to my question. The base class has to have a call to "registerBaseMethod" for the method that may be overridden.
Just as an idea, wouldn't it be more intuitive for the derived class to have syntax/method indicating that it is overriding the base? I can't off the top of my head think of how this could be done, but it took me awhile to figure out how the current manner works. Perhaps Type.overrideMethod(this, methodName, someFunctionReference).
Thanks,
William

You need to register the base method in the ArrayList class.

Juicy.Collections.ArrayList.registerBaseMethod(this, 'add');

Then your callBaseMethod should start resolving. However, you need to make one more small tweak - the arguments to the base method are passed as an array of arguments. So you would have:

Juicy.UI.TabPageCollection.callBaseMethod(this, 'add', [tabPage]);