An alternative to UBB.threads
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
FLocal/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementDefinition.vb

113 lines
4.5 KiB

'**************************************************
' 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
''' <summary>
''' Represents a way of describing an element.
''' </summary>
Public Structure BBCodeElementDefinition
Private __TagName As String
Private __RequireClosingTag As Boolean
Private __ReplacementFormat As String
''' <summary>
''' Gets the name of the element.
''' </summary>
<XmlAttribute()> _
Public Property TagName() As String
Get
Return __TagName
End Get
Set(ByVal value As String)
__TagName = value.ToUpperInvariant()
End Set
End Property
''' <summary>
''' Gets or sets the replacement format for this element.
''' </summary>
''' <value>The replacement format.</value>
''' <remarks>
''' <para>In order to use the any parameter in the replacement format use the following syntax: {paramName}.</para>
''' <para/>
''' <para>The parameter names are case insensitive.</para>
''' <para/>
''' <para>There are two reserved parameter keywords for formatting: DEFAULT and VALUE.</para>
''' <para><c>DEFAULT</c> : The text following the first equal sign after the name of the BBCode element.</para>
''' <para><c>VALUE</c>: The HTML generated by the BBCode between the start and end element tag.</para>
''' <para><example>[url=http://tempuri.org]text[/url]</example></para>
''' <para>In the example above the parameter DEFAULT would have the value "http://tempuri.org", while VALUE would be "text".</para>
''' <para/>
''' <para>To replace [url=http://tempuri.org]text[/url] the with &lt;a href="http://tempuri.org"&gt;text&lt;/a&gt; the following ReplacementFormat should be used:</para>
''' <example>
''' &lt;a href="{default|value}"&gt;{value|default}&lt;/a&gt;
''' </example>
''' <para>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.</para>
''' </remarks>
<XmlElement()> _
Public Property ReplacementFormat() As String
Get
Return __ReplacementFormat
End Get
Set(ByVal value As String)
__ReplacementFormat = value
End Set
End Property
''' <summary>
''' Gets or sets a value indicating if the element requires a closing tag.
''' </summary>
<XmlAttribute()> _
Public Property RequireClosingTag() As Boolean
Get
Return __RequireClosingTag
End Get
Set(ByVal value As Boolean)
__RequireClosingTag = value
End Set
End Property
''' <summary>Indicates whether this instance and a specified object are equal.</summary>
''' <returns>true if <paramref name="obj" /> and this instance are the same type and represent the same value; otherwise, false.</returns>
''' <param name="obj">Another object to compare to.</param>
''' <filterpriority>2</filterpriority>
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
''' <summary>Returns the hash code for this instance.</summary>
''' <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
''' <filterpriority>2</filterpriority>
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