C# Class Majestic12.HTMLchunk

Parsed HTML token that is either text, comment, script, open or closed tag as indicated by the oType variable.
Inheritance: IDisposable
Datei anzeigen Open project: arktronic/sevenauth Class Usage Examples

Public Properties

Property Type Description
MAX_PARAMS int
TEXT_CAPACITY int
bClosure bool
bComments bool
bEndClosure bool
bEntities bool
bHashMode bool
bLtEntity bool
cParamChars byte[]
iChunkLength int
iChunkOffset int
iParams int
oEnc Encoding
oHTML string
oParams object>.System.Collections.Generic.Dictionary
oType HTMLchunkType
sParams string[]
sTag string
sValues string[]

Public Methods

Method Description
AddParam ( string sParam, string sValue, byte cParamChar ) : void

Adds tag parameter to the chunk

Clear ( ) : void

Clears chunk preparing it for

ConvertParamsToHash ( ) : void

This function will convert parameters stored in sParams/sValues arrays into oParams hash Useful if generally parsing is done when bHashMode is FALSE. Hash operations are not the fastest, so its best not to use this function.

Dispose ( ) : void
GenerateHTML ( ) : string

Generates HTML based on current chunk's data Note: this is not a high performance method and if you want ORIGINAL HTML that was parsed to create this chunk then use relevant HTMLparser method to obtain such HTML then you should use function of parser: SetRawHTML

GenerateParamHTML ( string sParam, string sValue, char cParamChar ) : string

Generates HTML for param/value pair

GenerateParamsHTML ( ) : string

Generates HTML for params in this chunk

GetParamValue ( string sParam ) : string

Returns value of a parameter

HTMLchunk ( bool p_bHashMode ) : System

Initialises new HTMLchunk

MakeSafeParamValue ( string sLine, char cQuoteChar ) : string

Makes parameter value safe to be used in param - this will check for any conflicting quote chars, but not full entity-encoding

SetEncoding ( Encoding p_oEnc ) : void

Sets encoding to be used for conversion of binary data into string

Private Methods

Method Description
Dispose ( bool bDisposing ) : void

Method Details

AddParam() public method

Adds tag parameter to the chunk
public AddParam ( string sParam, string sValue, byte cParamChar ) : void
sParam string Parameter name (ie color)
sValue string Value of the parameter (ie white)
cParamChar byte
return void

Clear() public method

Clears chunk preparing it for
public Clear ( ) : void
return void

ConvertParamsToHash() public method

This function will convert parameters stored in sParams/sValues arrays into oParams hash Useful if generally parsing is done when bHashMode is FALSE. Hash operations are not the fastest, so its best not to use this function.
public ConvertParamsToHash ( ) : void
return void

Dispose() public method

public Dispose ( ) : void
return void

GenerateHTML() public method

Generates HTML based on current chunk's data Note: this is not a high performance method and if you want ORIGINAL HTML that was parsed to create this chunk then use relevant HTMLparser method to obtain such HTML then you should use function of parser: SetRawHTML
public GenerateHTML ( ) : string
return string

GenerateParamHTML() public method

Generates HTML for param/value pair
public GenerateParamHTML ( string sParam, string sValue, char cParamChar ) : string
sParam string Param
sValue string Value (empty if not specified)
cParamChar char
return string

GenerateParamsHTML() public method

Generates HTML for params in this chunk
public GenerateParamsHTML ( ) : string
return string

GetParamValue() public method

Returns value of a parameter
public GetParamValue ( string sParam ) : string
sParam string Parameter
return string

HTMLchunk() public method

Initialises new HTMLchunk
public HTMLchunk ( bool p_bHashMode ) : System
p_bHashMode bool Sets
return System

MakeSafeParamValue() public static method

Makes parameter value safe to be used in param - this will check for any conflicting quote chars, but not full entity-encoding
public static MakeSafeParamValue ( string sLine, char cQuoteChar ) : string
sLine string Line of text
cQuoteChar char Quote char used in param - any such chars in text will be entity-encoded
return string

SetEncoding() public method

Sets encoding to be used for conversion of binary data into string
public SetEncoding ( Encoding p_oEnc ) : void
p_oEnc System.Text.Encoding Encoding object
return void

Property Details

MAX_PARAMS public_oe static_oe property

Maximum number of parameters in a tag - should be high enough to fit most sensible cases
public static int MAX_PARAMS
return int

TEXT_CAPACITY public_oe static_oe property

Maximum default capacity of buffer that will keep data
public static int TEXT_CAPACITY
return int

bClosure public_oe property

If true then it must be closed tag
public bool bClosure
return bool

bComments public_oe property

If true then it must be comments tag
public bool bComments
return bool

bEndClosure public_oe property

If true then it must be closed tag and closure sign / was at the END of tag, ie this is a SOLO tag
public bool bEndClosure
return bool

bEntities public_oe property

True if entities were present (and transformed) in the original HTML
public bool bEntities
return bool

bHashMode public_oe property

If true then tag params will be kept in a hash rather than in a fixed size arrays. This will be slow down parsing, but make it easier to use.
public bool bHashMode
return bool

bLtEntity public_oe property

Set to true if < entity (tag start) was found
public bool bLtEntity
return bool

cParamChars public_oe property

Character used to quote param's value: it is taken actually from parsed HTML
public byte[] cParamChars
return byte[]

iChunkLength public_oe property

Length of the chunk in bHTML data array
public int iChunkLength
return int

iChunkOffset public_oe property

Offset in bHTML data array at which this chunk starts
public int iChunkOffset
return int

iParams public_oe property

Number of parameters and values stored in sParams array, OR in oParams hashtable if bHashMode is true
public int iParams
return int

oEnc public_oe property

Encoder to be used for conversion of binary data into strings, Encoding.Default is used by default, but it can be changed if top level user of the parser detects that encoding was different
public Encoding oEnc
return Encoding

oHTML public_oe property

For TAGS: it stores raw HTML that was parsed to generate thus chunk will be here UNLESS HTMLparser was configured not to store it there as it can improve performance

For TEXT or COMMENTS: actual text or comments - you MUST call Finalise(); first.

public string oHTML
return string

oParams public_oe property

Hashtable with tag parameters: keys are param names and values are param values. ONLY used if bHashMode is set to TRUE.
public System.Collections.Generic.Dictionary oParams
return object>.System.Collections.Generic.Dictionary

oType public_oe property

Chunk type showing whether its text, open or close tag, comments or script. WARNING: if type is comments or script then you have to manually call Finalise(); method in order to have actual text of comments/scripts in oHTML variable
public HTMLchunkType oType
return HTMLchunkType

sParams public_oe property

Param names will be stored here - actual number is in iParams. ONLY used if bHashMode is set to FALSE.
public string[] sParams
return string[]

sTag public_oe property

If its open/close tag type then this is where lowercased Tag will be kept
public string sTag
return string

sValues public_oe property

Param values will be stored here - actual number is in iParams. ONLY used if bHashMode is set to FALSE.
public string[] sValues
return string[]