Esempio n. 1
0
 /// <summary>
 /// Sets the named attribute to {value}
 /// </summary>
 public void SetAttribute(string attributeName, XmlString value)
 {
     if (_xmlElement == null)
     {
         _geckoElement.SetAttribute(attributeName, value.Unencoded);
     }
     else
     {
         _xmlElement.SetAttribute(attributeName, value.Unencoded);                       // This method will apply XML-encoding to its {value} parameter
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Sets the named attribute to {value}
 /// </summary>
 public void SetAttribute(string attributeName, XmlString value)
 {
     if (_xmlElement == null)
     {
         _geckoElement.SetAttribute(attributeName, value.Unencoded);
     }
     else
     {
         _xmlElement.SetAttribute(attributeName, value.Unencoded);
     }
 }
Esempio n. 3
0
        public void AddOrRemoveClass(string className, bool wanted)
        {
            var classes = GetAttribute("class").Split(' ').ToList();

            if (wanted)
            {
                if (!classes.Contains(className))
                {
                    classes.Add(className);
                }
            }
            else
            {
                classes.Remove(className);
            }

            // CSS class names can't contain punctuation other than underscore or hyphen,
            // so in terms of XML encoding, both FromUnencoded or FromXml will work fine because there's no special characters.
            // Just pick whichever one you want, don't fret about it.
            var classAttributeValue = XmlString.FromUnencoded(string.Join(" ", classes));

            SetAttribute("class", classAttributeValue);
        }
Esempio n. 4
0
 public static bool IsNullOrEmpty(XmlString xmlString) => String.IsNullOrEmpty(xmlString?.Xml);