private void VisitSheet(StyleSheet styleSheet) { foreach (StyleRule current in styleSheet.StyleRules) { this.m_Builder.BeginRule(current.Line); this.VisitBaseSelector(current.Selector); foreach (Property current2 in current.Declarations) { this.m_Builder.BeginProperty(current2.Name); StyleSheetImporterImpl.VisitValue(this.m_Errors, this.m_Builder, current2.Term); this.m_Builder.EndProperty(); } this.m_Builder.EndRule(); } }
internal static void VisitValue(StyleSheetImportErrors errors, StyleSheetBuilder ssb, Term term) { PrimitiveTerm primitiveTerm = term as PrimitiveTerm; HtmlColor htmlColor = term as HtmlColor; GenericFunction genericFunction = term as GenericFunction; TermList termList = term as TermList; if (term == Term.Inherit) { ssb.AddValue(StyleValueKeyword.Inherit); } else if (primitiveTerm != null) { string text = term.ToString(); UnitType primitiveType = primitiveTerm.PrimitiveType; switch (primitiveType) { case UnitType.String: { string value = text.Trim(new char[] { '\'', '"' }); ssb.AddValue(value, StyleValueType.String); goto IL_F9; } case UnitType.Uri: IL_63: if (primitiveType != UnitType.Number && primitiveType != UnitType.Pixel) { errors.AddSemanticError(StyleSheetImportErrorCode.UnsupportedUnit, primitiveTerm.ToString()); return; } ssb.AddValue(primitiveTerm.GetFloatValue(UnitType.Pixel).Value); goto IL_F9; case UnitType.Ident: { StyleValueKeyword keyword; if (StyleSheetImporterImpl.TryParseKeyword(text, out keyword)) { ssb.AddValue(keyword); } else { ssb.AddValue(text, StyleValueType.Enum); } goto IL_F9; } } goto IL_63; IL_F9 :; } else if (htmlColor != null) { Color value2 = new Color((float)htmlColor.R / 255f, (float)htmlColor.G / 255f, (float)htmlColor.B / 255f, (float)htmlColor.A / 255f); ssb.AddValue(value2); } else if (genericFunction != null) { primitiveTerm = (genericFunction.Arguments.FirstOrDefault <Term>() as PrimitiveTerm); if (genericFunction.Name == "resource" && primitiveTerm != null) { string value3 = primitiveTerm.Value as string; ssb.AddValue(value3, StyleValueType.ResourcePath); } else { errors.AddSemanticError(StyleSheetImportErrorCode.UnsupportedFunction, genericFunction.Name); } } else if (termList != null) { foreach (Term current in termList) { StyleSheetImporterImpl.VisitValue(errors, ssb, current); } } else { errors.AddInternalError(term.GetType().Name); } }