CssParser
Parser to parse CSS stylesheet source string into CSS objects.
构造函数
方法
AddProperty(string, string, Dictionary<string, string>)
Add the given property to the given properties collection, if the property is complex containing multiple css properties then parse them and add the inner properties.
- propName
- the name of the css property to add
- propValue
- the value of the css property to add
- properties
- the properties collection to add to
FeedStyleBlock(CssData, string, string)
Feeds the style with a block about the specific media. When no media is specified, "all" will be used.
- cssData
- block
- the CSS block to handle
- media
- optional: the media (default - all)
ParseBorder(string, string, string, string)
- value
- width
- style
- color
ParseBorderColor(string, int, int) : string
Parse the given substring to extract border style substring. Assume given substring is not empty and all indexes are valid!
返回值: found border width value or null
ParseBorderColorProperty(string, Dictionary<string, string>)
Parse a complex border color property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- properties
- the properties collection to add the specific properties to
ParseBorderProperty(string, string, Dictionary<string, string>)
Parse a complex border property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- direction
- the left, top, right or bottom direction of the border to parse
- properties
- the properties collection to add the specific properties to
ParseBorderStyle(string, int, int) : string
Parse the given substring to extract border style substring. Assume given substring is not empty and all indexes are valid!
返回值: found border width value or null
ParseBorderStyleProperty(string, Dictionary<string, string>)
Parse a complex border style property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- properties
- the properties collection to add the specific properties to
ParseBorderWidth(string, int, int) : string
Parse the given substring to extract border width substring. Assume given substring is not empty and all indexes are valid!
返回值: found border width value or null
ParseBorderWidthProperty(string, Dictionary<string, string>)
Parse a complex border width property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- properties
- the properties collection to add the specific properties to
ParseColor(string) : RColor
Parses a color value in CSS style; e.g. #ff0000, red, rgb(255,0,0), rgb(100%, 0, 0)
- colorStr
- color string value to parse
返回值: color value
ParseColorProperty(string, string, Dictionary<string, string>)
Parse color property to add only valid color.
- propName
- the name of the css property to add
- propValue
- the value of the css property to add
- properties
- the properties collection to add to
ParseCssBlock(string, string) : CssBlock
Parse single CSS block source into CSS block instance.
- className
- the name of the css class of the block
- blockSource
- the CSS block to parse
返回值: the created CSS block instance
ParseCssBlockImp(string, string) : CssBlock
Parse single CSS block source into CSS block instance.
- className
- the name of the css class of the block
- blockSource
- the CSS block to parse
返回值: the created CSS block instance
ParseCssBlockProperties(string) : Dictionary<string, string>
Parse the properties of the given css block into a key-value dictionary.
- blockSource
- the raw css block to parse
返回值: dictionary with parsed css block properties
ParseCssBlockSelector(string, string) : List<CssBlockSelectorItem>
Parse css block selector to support hierarchical selector (p class1 > class2).
- className
- the class selector to parse
- firstClass
- return the main class the css block is on
返回值: returns the hierarchy of classes or null if single class selector
ParseFontFamily(string) : string
Parse a complex font family css property to check if it contains multiple fonts and if the font exists. returns the font family name to use or 'inherit' if failed.
- value
- the font-family value to parse
返回值: parsed font-family value
ParseFontFamilyProperty(string) : string
Parse a complex font family css property to check if it contains multiple fonts and if the font exists. returns the font family name to use or 'inherit' if failed.
- propValue
- the value of the property to parse
返回值: parsed font-family value
ParseFontProperty(string, Dictionary<string, string>)
Parse a complex font property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- properties
- the properties collection to add the specific properties to
ParseLengthProperty(string, string, Dictionary<string, string>)
Parse length property to add only valid lengths.
- propName
- the name of the css property to add
- propValue
- the value of the css property to add
- properties
- the properties collection to add to
ParseMarginProperty(string, Dictionary<string, string>)
Parse a complex margin property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- properties
- the properties collection to add the specific properties to
ParseMediaStyleBlocks(CssData, string)
Parse given stylesheet for media CSS blocks This blocks are added under the specific media block they are found.
- cssData
- the CSS data to fill with parsed CSS objects
- stylesheet
- the stylesheet to parse
ParsePaddingProperty(string, Dictionary<string, string>)
Parse a complex padding property value that contains multiple css properties into specific css properties.
- propValue
- the value of the property to parse to specific values
- properties
- the properties collection to add the specific properties to
ParseStyleBlocks(CssData, string)
Parse given stylesheet for CSS blocks This blocks are added under the "all" keyword.
- cssData
- the CSS data to fill with parsed CSS objects
- stylesheet
- the stylesheet to parse
ParseStyleSheet(string, bool)
Parse the given stylesheet source to CSS blocks dictionary. The CSS blocks are organized into two level buckets of media type and class name. Root media type are found under 'all' bucket. If is true the parsed css blocks are added to the default css data (as defined by W3), merged if class name already exists. If false only the data in the given stylesheet is returned.
- stylesheet
- raw css stylesheet to parse
- combineWithDefault
- true - combine the parsed css data with default css data, false - return only the parsed css data
返回值: the CSS data with parsed CSS objects (never null)
ParseStyleSheet(CssData, string)
Parse the given stylesheet source to CSS blocks dictionary. The CSS blocks are organized into two level buckets of media type and class name. Root media type are found under 'all' bucket. The parsed css blocks are added to the given css data, merged if class name already exists.
- cssData
- the CSS data to fill with parsed CSS objects
- stylesheet
- raw css stylesheet to parse
RemoveStylesheetComments(string) : string
Remove comments from the given stylesheet.
- stylesheet
- the stylesheet to remove comments from
返回值: stylesheet without comments
SplitMultiDirectionValues(string, string, string, string, string)
Split multi direction value into the proper direction values (left, top, right, bottom).
SplitValues(string, char) : string[]
Split the value by the specified separator; e.g. Useful in values like 'padding:5 4 3 inherit'
- value
- Value to be splitted
- separator
返回值: Splitted and trimmed values
字段
_cssBlockSplitters : char[]
split CSS rule
_cssClassTrimChars : char[]
The chars to trim the css class name by
_valueParser : CssValueParser
Utility for value parsing.