C# Класс Majestic12.HTMLchunk

Parsed HTML token that is either text, comment, script, open or closed tag as indicated by the oType variable.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
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[]

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
Dispose ( bool bDisposing ) : void

Описание методов

AddParam() публичный Метод

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
Результат void

Clear() публичный Метод

Clears chunk preparing it for
public Clear ( ) : void
Результат void

ConvertParamsToHash() публичный Метод

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
Результат void

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

GenerateHTML() публичный Метод

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
Результат string

GenerateParamHTML() публичный Метод

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
Результат string

GenerateParamsHTML() публичный Метод

Generates HTML for params in this chunk
public GenerateParamsHTML ( ) : string
Результат string

GetParamValue() публичный Метод

Returns value of a parameter
public GetParamValue ( string sParam ) : string
sParam string Parameter
Результат string

HTMLchunk() публичный Метод

Initialises new HTMLchunk
public HTMLchunk ( bool p_bHashMode ) : System
p_bHashMode bool Sets
Результат System

MakeSafeParamValue() публичный статический Метод

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
Результат string

SetEncoding() публичный Метод

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
Результат void

Описание свойств

MAX_PARAMS публичное статическое свойство

Maximum number of parameters in a tag - should be high enough to fit most sensible cases
public static int MAX_PARAMS
Результат int

TEXT_CAPACITY публичное статическое свойство

Maximum default capacity of buffer that will keep data
public static int TEXT_CAPACITY
Результат int

bClosure публичное свойство

If true then it must be closed tag
public bool bClosure
Результат bool

bComments публичное свойство

If true then it must be comments tag
public bool bComments
Результат bool

bEndClosure публичное свойство

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
Результат bool

bEntities публичное свойство

True if entities were present (and transformed) in the original HTML
public bool bEntities
Результат bool

bHashMode публичное свойство

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
Результат bool

bLtEntity публичное свойство

Set to true if < entity (tag start) was found
public bool bLtEntity
Результат bool

cParamChars публичное свойство

Character used to quote param's value: it is taken actually from parsed HTML
public byte[] cParamChars
Результат byte[]

iChunkLength публичное свойство

Length of the chunk in bHTML data array
public int iChunkLength
Результат int

iChunkOffset публичное свойство

Offset in bHTML data array at which this chunk starts
public int iChunkOffset
Результат int

iParams публичное свойство

Number of parameters and values stored in sParams array, OR in oParams hashtable if bHashMode is true
public int iParams
Результат int

oEnc публичное свойство

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
Результат Encoding

oHTML публичное свойство

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
Результат string

oParams публичное свойство

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
Результат object>.System.Collections.Generic.Dictionary

oType публичное свойство

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
Результат HTMLchunkType

sParams публичное свойство

Param names will be stored here - actual number is in iParams. ONLY used if bHashMode is set to FALSE.
public string[] sParams
Результат string[]

sTag публичное свойство

If its open/close tag type then this is where lowercased Tag will be kept
public string sTag
Результат string

sValues публичное свойство

Param values will be stored here - actual number is in iParams. ONLY used if bHashMode is set to FALSE.
public string[] sValues
Результат string[]