This content has been marked as final. Show 3 replies
is it possible for you to return a reference of mx.collection.IList instead of ArrayCollection?
If so, you can simply extend ArrayCollection class and throw on all the methods of IList interface that modify the collection in any way. And when it comes to returning a reference of type IList, just return a reference of this new arraycollection (which would essentially be a copy of original arrayclloection only this one would throw on any modification attempts)
IList... hmm... yes that should do it. :-)
I'll give it a try!
I set out to extend ArrayCollection and implement IList, and it will certainly work.
I'm not even sure I'll bother implementing IList; perhaps I'll just try to figure out which methods would be "dangerous" in this particular case, and just override them.
The only drawback is that the errors obviously won't be thrown until the app is actually running. It would have been nice to hide the undesired methods altogether - so they wouldn't even show up in the code hinting. (Is that doable..?)
Anyway, here's a tiny snippet of what I'll be doing in the first place.