예제 #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
     }
 }
예제 #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);
     }
 }
예제 #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);
        }
예제 #4
0
 public static bool IsNullOrEmpty(XmlString xmlString) => String.IsNullOrEmpty(xmlString?.Xml);