/// <summary> /// Extracts the inline styles, optimizes CSS and adds CSS classes in the head section for current page /// </summary> /// <param name="xmlDoc">A reference to a XmlDocument instance.</param> public void Filter(ref System.Xml.XmlDocument xmlDoc) { XmlNode body = xmlDoc.GetElementsByTagName("body")[0]; XmlNode head = xmlDoc.GetElementsByTagName("head")[0]; if (head == null) { head = xmlDoc.CreateNode(XmlNodeType.Element, "head", xmlDoc.NamespaceURI); body.ParentNode.InsertBefore(head, body); } //step1: inline CSS for existing CSS classes and ids, for better manipulation at step2 and step3 CSSUtil.InlineCSS(ref xmlDoc); //step2: convert all inlined style to CSS classes //(including, but not limited to, those generated at step1) body = CSSUtil.ConvertInlineStylesToCssClasses(body, ref xmlDoc, ref counter, ref cssClasses); //step3: optimize CSS by grouping selectors with the same properties cssClasses = CSSUtil.GroupCSSSelectors(cssClasses); InsertCssClassesInHeader(ref head, ref xmlDoc); }
public void CreateDiscriminator(object info, System.Xml.XmlDocument xmlDocument) { var node = xmlDocument.CreateNode(XmlNodeType.Element, Constants.DISCRIMINATOR, ""); node.InnerText = ReflectionUtils.GetTypeFullName_With_AssemblyName_WihoutVersion(info.GetType()); xmlDocument.DocumentElement.AppendChild(node); }
/// <summary> /// Stores the numeric option as an XML Node (calls base implementation) /// </summary> /// <param name="doc">The XML document to which the node will be added</param> /// <returns>The XML node containing the information of numeric option</returns> internal XmlNode saveXML(System.Xml.XmlDocument doc) { XmlNode node = base.saveXML(doc); //Min_Value XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", ""); minNode.InnerText = this.min_value.ToString(); node.AppendChild(minNode); //Max_Value XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", ""); maxNode.InnerText = this.max_value.ToString(); node.AppendChild(maxNode); if (this.stepFunction != null) { //StepFunction XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", ""); stepNode.InnerText = this.stepFunction.ToString(); node.AppendChild(stepNode); } if (values != null) { //Values XmlNode valuesNode = doc.CreateNode(XmlNodeType.Element, "values", ""); String valuesAsString = ""; for (int i = 0; i < values.Count(); i++) { valuesAsString += values[i] + ";"; } // remove last ; valuesAsString = valuesAsString.Substring(0, valuesAsString.Count() - 2); valuesNode.InnerText = valuesAsString; node.AppendChild(valuesNode); } //DefaultValue XmlNode defNode = doc.CreateNode(XmlNodeType.Element, "defaultValue", ""); defNode.InnerText = this.defaultValue.ToString(); node.AppendChild(defNode); return node; }
/// <summary> /// Stores the numeric option as an XML Node (calls base implementation) /// </summary> /// <param name="doc">The XML document to which the node will be added</param> /// <returns>The XML node containing the information of numeric option</returns> internal XmlNode saveXML(System.Xml.XmlDocument doc) { XmlNode node = base.saveXML(doc); //Min_Value XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", ""); minNode.InnerText = this.min_value.ToString(); node.AppendChild(minNode); //Max_Value XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", ""); maxNode.InnerText = this.max_value.ToString(); node.AppendChild(maxNode); //StepFunction XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", ""); stepNode.InnerText = this.stepFunction.ToString(); node.AppendChild(stepNode); //DefaultValue XmlNode defNode = doc.CreateNode(XmlNodeType.Element, "defaultValue", ""); defNode.InnerText = this.defaultValue.ToString(); node.AppendChild(defNode); return node; }