[Ironruby-core] Ruby and ObservableCollection
curth at microsoft.com
Thu Oct 22 13:52:40 EDT 2009
ObservableCollection<T> is an IList, so it should pick up Enumerable support through IListOps, no?
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jimmy Schementi
Sent: Thursday, October 22, 2009 10:41 AM
To: Hans Hugli; ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Ruby and ObservableCollection
For Ruby and Python specific questions, the public mailing lists are preferred.
Ruby: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Python: users at lists.ironpython.com<mailto:users at lists.ironpython.com>
So I'm moving this to the IronRuby mailing list ...
To address your question, System.Collections.ObjectModel.ObservableCollection<T> has all protected members, so if you just create an instance and try to call a method you should see this error:
rb> $oc = System::Collections::ObjectModel::ObservableCollection[String].new
rb> $oc.insert_item "hi"
System.MissingMethodException: CLR protected method `insert_item' called for :System::Collections::ObjectModel::ObservableCollection[String]; CLR protected methods can only be called with a receiver whose class is a Ruby subclass of the class declaring the method
However, if I subclass ObservableCollection and try to call methods I get an assert from RubyMethodGroupInfo.GetVisibleOverloads(CallArguments args, IList`1 overloads) and an exception:
rb> class OCSubclass < System::Collections::ObjectModel::ObservableCollection[String]
... def initialize
... self.insert_item "hi"
rb> $ocsub = OCSubclass.new
System.ArgumentNullException: Value cannot be null.
Parameter name: methods
Tomas, have any idea?
From: Hans Hugli
Sent: Thursday, October 22, 2009 9:29 AM
To: DLR Discussion
Subject: Ruby and ObservableCollection
Is ObservableCollection implemented in IronRuby?
I am working with a student that can instantiate one [[ ObservableCollection[String].new ]], but calling the add method with a string results in a NullReferenceException.
Please respond to me directly. I just added myself to the alias, but pending owner approval.
If this is not the appropriate alias for this question, please let me know.
Hans Hugli Innovative Web team
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironruby-core