Hi all,
Been reading up on DNN Modual programming, and although I understand the role of the DataProvider Class, the source code has me a bit confused. It appears to me that the code contained in the class actually references and instantiates the very same class itself. Is that true? Is that even possible?
As you can see in the vb template-generated code below, The class is defined as "Public MustInherit Class DataProvider", yet there is code inside the class that references the very same class that is defined (i.e. "Private Shared objProvider As DataProvider = Nothing" and "Public Shared Shadows Function Instance() As DataProvider", and also in the "CType" function.
Could someone please explain how this is even possible?
Thanks in advance :)
DataProvider.vb
Public MustInherit Class DataProvider
#Region “Shared/Static Methods”
‘ singleton reference to the instantiated object
Private Shared objProvider As DataProvider = Nothing
‘ constructor
Shared Sub New()
CreateProvider()
End Sub
‘ dynamically create provider
Private Shared Sub CreateProvider()
objProvider = CType(Framework.Reflection.CreateObject(“data“,
“DotNetNuke.Modules.Html“, “DotNetNuke.Modules.Html“), DataProvider)
End Sub
‘ return the provider
Public Shared Shadows Function Instance() As DataProvider
Return objProvider
End Function
#End Region
#Region “Abstract methods”
‘ …
Public MustOverride Function
GetHtmlText(ByVal moduleId As Integer) As IDataReader
‘ …
#End Region
End Class