Headless.XPathNavigableExtensions.SetChecked C# (CSharp) Method

SetChecked() public static method

Sets the checked state of the specified navigable instance.
public static SetChecked ( this navigable, bool value ) : void
navigable this /// The navigable. ///
value bool /// if set to true [value]. ///
return void
        public static void SetChecked(this IXPathNavigable navigable, bool value)
        {
            var navigator = navigable.GetNavigator();

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

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

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