'**************************************************
' FILE : BBCodeNode.vb
' AUTHOR : Paulo Santos
' CREATION : 4/29/2009 11:30:13 AM
' COPYRIGHT : Copyright © 2009
' PJ on Development
' All Rights Reserved.
'
' Description:
' Represents the basic node of an BBCode document
'
' Change log:
' 0.1 4/29/2009 11:30:13 AM
' Paulo Santos
' Created.
'***************************************************
'''
''' Represents the basic node of an BBCode document.
'''
Public MustInherit Class BBCodeNode(Of TContext As Class)
Private __Parent As BBCodeNode(Of TContext)
Private __Parser As BBCodeParser(Of TContext)
''' Initializes an instance of the class.
''' This is the default constructor for this class.
Protected Sub New()
End Sub
''' Initializes an instance of the class.
''' The parser used to create this element.
Protected Sub New(ByVal parser As BBCodeParser(Of TContext))
__Parser = parser
End Sub
'''
''' Gets the parent node.
'''
Public ReadOnly Property Parent() As BBCodeNode(Of TContext)
Get
Return __Parent
End Get
End Property
'''
''' Gets the that create this instance of the .
'''
Protected Friend ReadOnly Property Parser() As BBCodeParser(Of TContext)
Get
Return __Parser
End Get
End Property
'''
''' When implemented in a derived class, transforms this instance of into its desired text representation.
'''
''' An object that implements the interface.
''' The text formatted by the .
Public MustOverride Function Format(ByVal context As TContext, ByVal formatter As ITextFormatter(Of TContext)) As String
'''
''' When implemented in a derived class, gets or sets the inner BBCode.
'''
''' The BBCode between the start and end tags.
Public MustOverride Property InnerBBCode() As String
'''
''' When implemented in a derived class, gets the outer BBCode.
'''
''' The BBCode of this instance of the .
Public MustOverride ReadOnly Property OuterBBCode() As String
'''
''' When implemented in a derived class, gets or sets the plain text of the node.
'''
''' The plain text between the start and end tags.
Public MustOverride Property InnerText() As String
'''
''' Sets the of this instance.
'''
''' The new parser of this instance.
Friend Sub SetParser(ByVal parser As BBCodeParser(Of TContext))
__Parser = parser
End Sub
'''
''' The the parent node of this instance of the .
'''
''' The parent node.
Protected Friend Sub SetParent(ByVal parentNode As BBCodeNode(Of TContext))
Dim element = TryCast(parentNode, BBCodeElement(Of TContext))
If (element Is Nothing) OrElse (String.IsNullOrEmpty(element.Name)) Then
__Parent = Nothing
Else
__Parent = element
End If
End Sub
End Class