[12762] | 1 | // <developer>niklas@protocol7.com</developer>
|
---|
| 2 | // <completed>100</completed>
|
---|
| 3 |
|
---|
| 4 | using System;
|
---|
| 5 | using System.Collections.Generic;
|
---|
| 6 | using System.Text.RegularExpressions;
|
---|
| 7 |
|
---|
| 8 | namespace SharpVectors.Dom.Css
|
---|
| 9 | {
|
---|
| 10 | /// <summary>
|
---|
| 11 | /// The CSSUnknownRule interface represents an at-rule not supported by this user agent.
|
---|
| 12 | /// </summary>
|
---|
| 13 | public sealed class CssUnknownRule : CssRule, ICssUnknownRule
|
---|
| 14 | {
|
---|
| 15 | #region Static members
|
---|
| 16 |
|
---|
| 17 | // TODO: should also find blocks
|
---|
| 18 | private static Regex regex = new Regex(@"^@[^;]+;");
|
---|
| 19 |
|
---|
| 20 | internal static CssRule Parse(ref string css, object parent, bool readOnly,
|
---|
| 21 | IList<string> replacedStrings, CssStyleSheetType origin)
|
---|
| 22 | {
|
---|
| 23 | Match match = regex.Match(css);
|
---|
| 24 | if(match.Success)
|
---|
| 25 | {
|
---|
| 26 | CssUnknownRule rule = new CssUnknownRule(parent, readOnly, replacedStrings, origin);
|
---|
| 27 | css = css.Substring(match.Length);
|
---|
| 28 | return rule;
|
---|
| 29 | }
|
---|
| 30 | else
|
---|
| 31 | {
|
---|
| 32 | // didn't match => do nothing
|
---|
| 33 | return null;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | #endregion
|
---|
| 38 |
|
---|
| 39 | #region Constructors
|
---|
| 40 |
|
---|
| 41 | /// <summary>
|
---|
| 42 | /// The constructor for CssUnknownRule
|
---|
| 43 | /// </summary>
|
---|
| 44 | internal CssUnknownRule(object parent, bool readOnly,
|
---|
| 45 | IList<string> replacedStrings, CssStyleSheetType origin)
|
---|
| 46 | : base(parent, readOnly, replacedStrings, origin)
|
---|
| 47 | {
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | #endregion
|
---|
| 51 |
|
---|
| 52 | #region Implementation of ICssRule
|
---|
| 53 | /// <summary>
|
---|
| 54 | /// The type of the rule. The expectation is that binding-specific casting methods can be used to cast down from an instance of the CSSRule interface to the specific derived interface implied by the type.
|
---|
| 55 | /// </summary>
|
---|
| 56 | public override CssRuleType Type
|
---|
| 57 | {
|
---|
| 58 | get
|
---|
| 59 | {
|
---|
| 60 | return CssRuleType.UnknownRule;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | #endregion
|
---|
| 64 | }
|
---|
| 65 | }
|
---|