سؤال

I have knowledge on C++ and C#, but COM is an Alien to me. I have a VC++ COM DLL in which all the methods of the interface ISAXContentHandler (of msxml6.DLL) like startElement(), endElement,processingInstructions(), characters(), etc.. are implemented. i.e these interface methods are given an implentation in the VC++ COM DLL. I want to convert this VC++ COM DLL to C# DLL so that I can call this converted C# DLL from my C# application.

I am not understanding that FROM WHERE ARE THESE INTERFACE METHODS BEING CALLED. Because there is NO "Function Call statement" being made from within my VC++ COM DLL.

For Example: ----- one of the interface methods implemented in the VC++ COM DLL starts like this- -->

  **HRESULT STDMETHODCALLTYPE ContentHandler_SAX::startElement( 
        /* [in] */ wchar_t __RPC_FAR *pwchNamespaceUri,
        /* [in] */ int cchNamespaceUri,
        /* [in] */ wchar_t __RPC_FAR *pwchLocalName,
        /* [in] */ int cchLocalName,
        /* [in] */ wchar_t __RPC_FAR *pwchRawName,
        /* [in] */ int cchRawName,
        /* [in] */ ISAXAttributes __RPC_FAR *pAttributes)**

The clas is implementing ISAXContentHAndler interface from msxml6.dll.

I just know that SAXContentHandler is a XML parser. I dont know what are these parameters for this function and also they are using _RPC keyword along with d parameter name. And I dont understand, FROM WHERE are these functions being called.

هل كانت مفيدة؟

المحلول

SAX Parser is asynchronous (event based) parser - generally, you start the parser giving it xml file/stream and it will raise events as it encounters various xml nodes. Being COM library, it uses COM event model where generally component (parser in this case) would define an callback interface (there are other interfaces that allowed to register for events etc).

So ISAXContentHAndler is an callback interface that is supposed to be implemented by code using the parser. You will find that somewhere in code, SAXXMLReader component being created and then the contentHandler property on ISAXXMLReader being set to the instance of class that is implementing ISAXContentHAndler.

You will find calls made to this interface in your code because its the SAX parser that would be calling methods on this interface - for example, whenever it encounters start tag of any element, it would call startElement method on this interface.

See these links to understand SAX better: http://msdn.microsoft.com/en-us/library/ms753774(v=VS.85).aspx http://msdn.microsoft.com/en-us/library/ms763771(v=VS.85).aspx

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top