I am tired of turning one html object into another. One way to do so would be to convert them to ihtmldomnode and then back
So here we go
vb.net Code:
<Extension()> Public Function convertTo(Of Somethingelse)(ByVal node As mshtml.IHTMLDOMNode) As Somethingelse Return CType(node, Somethingelse) End Function <Extension()> Public Function toNode(Of something)(ByVal someStuff As something) As mshtml.IHTMLDOMNode Return CType(someStuff, mshtml.IHTMLDOMNode) End Function 'Why Can't I do this '<Extension()> 'Public Function CtypeReloaded(Of something, somethingelse)(ByVal someStuff As something) As somethingelse ' Return CType(someStuff, somethingelse) 'Error 1 Value of type 'something' cannot be converted to 'somethingelse'. \\work\c\business\fromwork\currentprojects\program\library\vb.net\internetAccessSupporter.vb 20 22 googlepages2 ' Return CType("", somethingelse) 'End Function 'I like this one better <Extension()> Public Function CtypeNode(Of Something, Somethingelse)(ByVal someStuff As Something) As Somethingelse Dim node = CType(someStuff, mshtml.IHTMLDOMNode) 'Error 1 Value of type 'something' cannot be converted to 'somethingelse'. \\work\c\business\fromwork\currentprojects\program\library\vb.net\internetAccessSupporter.vb 20 22 googlepages2 Return CType(node, Somethingelse) 'For some reason Return CType(someStuff, Somethingelse) direct doesn't work End Function




Reply With Quote