/// <summary>Toggle the active state of the <see cref="IHostfileEntry"/> with the specified <paramref name="uniqueIdentifier"/>.</summary> /// <param name="uniqueIdentifier">The unique identifier of an <see cref="IHostfileEntry"/> object.</param> /// <returns>True if the active state of the <see cref="IHostfileEntry"/> with the specified <paramref name="uniqueIdentifier"/> was successfully toggled; otherwise false.</returns> public bool ToggleActiveStateObsolete(Guid uniqueIdentifier) { IHostfileEntry item = this.GetElementBy(uniqueIdentifier); if (item != null && item.IsActivatable) { ActivatableHostfileEntry activatableItem = item as ActivatableHostfileEntry; if (activatableItem != null) { bool currentState = activatableItem.IsActive; activatableItem.IsActive = !currentState; bool newState = activatableItem.IsActive; return(currentState != newState); } } return(false); }
/// <summary>Toggle the active state of the specified <paramref name="activatableHostfileEntry"/>.</summary> /// <param name="activatableHostfileEntry">A <see cref="IHostfileEntry"/> object.</param> /// <returns>True if the active state of the specified <see cref="IHostfileEntry"/> was successfully toggled; otherwise false.</returns> public bool ToggleActiveState(ActivatableHostfileEntry activatableHostfileEntry) { /* abort if parameter is null */ if (activatableHostfileEntry == null) { return false; } /* toggle host status */ if (activatableHostfileEntry.HasParent) { activatableHostfileEntry.ToggleActiveState(); return true; } /* toggle group status */ return this.HostFileInstance.ToggleActiveState(activatableHostfileEntry.UniqueIdentifier); }