Headless.XPathNavigableExtensions.SetSelected C# (CSharp) Method

SetSelected() public static method

Sets the selected.
public static SetSelected ( this navigable, bool value ) : void
navigable this /// The navigable. ///
value bool /// if set to true [value]. ///
return void
        public static void SetSelected(this IXPathNavigable navigable, bool value)
        {
            var navigator = navigable.GetNavigator();

            var hasAttribute = navigator.MoveToAttribute("selected", string.Empty);

            if (hasAttribute == value)
            {
                // No change is required
                return;
            }

            if (value)
            {
                // Set the attribute
                navigator.SetAttribute(string.Empty, "selected", string.Empty, "selected");
            }
            else
            {
                // Remove the checked attribute if it exists
                navigator.DeleteSelf();
            }
        }