I have MyTextInputStream which is a subclass of TextInputStream
I’m having troubles with the shared open method.
Shared Function Open(file As FolderItem) As MyTextInputStream
This throws an exception of class IllegalCastExeption …
I must be confused. Must I implement other methods before I can use this?
like a copy constructor assignment constructor etc?
Your Open shared method should be creating an instance of your class and returning that… In the constructor of your class, you would do the TextInputStream open and store the results to an instance property…
Into an instance property… of type TextInputStream which is a public property of the class?
I’m confused does my class constructor have a FolderItem as a parameter?
You could either use a FolderItem or a TextInputStream (for TextInputStream, you would just need to save the passed parameter to a property… I would recommend making the constructor and the property private, so they can’t be changed from outside of the instance…
Constructor(file As FolderItem)
me.Stream = TextInputStream.Open(file)
What you need is
return New MyTextInputStream(TextInputStream.Open(file))
Where you have a constructor that takes a TextInputStream and stores it in a private property. You can’t subclass something like TextInputStream directly, so you have to create a wrapper that mimics the api of a TextInputStream, but really just passes commands directly to a privately held TextInputStream and acts on the results.
That didn’t compile…
[quote]Not enough arguments: missing integer value for parmeter “handle”
return new MyTextInputStream(TextInput.Open(file))
TextInput.Open <-- TextInputStream.Open
There might be other parameters required, so go take a peek at the language reference…