'**************************************************
' FILE : BBCodeElementDefinition.vb
' AUTHOR : Paulo Santos
' CREATION : 4/29/2009 10:52:11 PM
' COPYRIGHT : Copyright © 2009
' PJ on Development
' All Rights Reserved.
'
' Description:
' TODO: Add file description
'
' Change log:
' 0.1 4/29/2009 10:52:11 PM
' Paulo Santos
' Created.
'***************************************************
Imports System.Xml.Serialization
'''
''' Represents a way of describing an element.
'''
Public Structure BBCodeElementDefinition
Private __TagName As String
Private __RequireClosingTag As Boolean
Private __ReplacementFormat As String
'''
''' Gets the name of the element.
'''
_
Public Property TagName() As String
Get
Return __TagName
End Get
Set(ByVal value As String)
__TagName = value.ToUpperInvariant()
End Set
End Property
'''
''' Gets or sets the replacement format for this element.
'''
''' The replacement format.
'''
''' In order to use the any parameter in the replacement format use the following syntax: {paramName}.
'''
''' The parameter names are case insensitive.
'''
''' There are two reserved parameter keywords for formatting: DEFAULT and VALUE.
''' DEFAULT : The text following the first equal sign after the name of the BBCode element.
''' VALUE: The HTML generated by the BBCode between the start and end element tag.
''' [url=http://tempuri.org]text[/url]
''' In the example above the parameter DEFAULT would have the value "http://tempuri.org", while VALUE would be "text".
'''
''' To replace [url=http://tempuri.org]text[/url] the with <a href="http://tempuri.org">text</a> the following ReplacementFormat should be used:
'''
''' <a href="{default|value}">{value|default}</a>
'''
''' The example above, will set the href attribute with either the default value or the text inside the [url] element. The pipe (|) implies in finding the first non-empty attribute.
'''
_
Public Property ReplacementFormat() As String
Get
Return __ReplacementFormat
End Get
Set(ByVal value As String)
__ReplacementFormat = value
End Set
End Property
'''
''' Gets or sets a value indicating if the element requires a closing tag.
'''
_
Public Property RequireClosingTag() As Boolean
Get
Return __RequireClosingTag
End Get
Set(ByVal value As Boolean)
__RequireClosingTag = value
End Set
End Property
''' Indicates whether this instance and a specified object are equal.
''' true if and this instance are the same type and represent the same value; otherwise, false.
''' Another object to compare to.
''' 2
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If Not (TypeOf obj Is BBCodeElementDefinition) Then
Return False
End If
Return (Me.TagName = obj.TagName AndAlso Me.ReplacementFormat = obj.ReplacementFormat AndAlso Me.RequireClosingTag = obj.RequireClosingTag)
End Function
''' Returns the hash code for this instance.
''' A 32-bit signed integer that is the hash code for this instance.
''' 2
Public Overrides Function GetHashCode() As Integer
Dim hash As Long = Me.TagName.GetHashCode() + Me.ReplacementFormat.GetHashCode() + Me.RequireClosingTag.GetHashCode()
Return hash And Integer.MinValue
End Function
Public Shared Operator =(ByVal left As BBCodeElementDefinition, ByVal right As BBCodeElementDefinition) As Boolean
Return left.Equals(right)
End Operator
Public Shared Operator <>(ByVal left As BBCodeElementDefinition, ByVal right As BBCodeElementDefinition) As Boolean
Return Not left = right
End Operator
End Structure