public static void RemoveCustomVariable(CustomVariable customVariable, List<string> additionalFilesToRemove)
{
// additionalFilesToRemove is added to keep this consistent with other remove methods
IElement iElement = ObjectFinder.Self.GetElementContaining(customVariable);
if (iElement == null || !iElement.CustomVariables.Contains(customVariable))
{
throw new ArgumentException();
}
else
{
iElement.CustomVariables.Remove(customVariable);
iElement.RefreshStatesToCustomVariables();
List<EventResponseSave> eventsReferencedByVariable = iElement.GetEventsOnVariable(customVariable.Name);
foreach (EventResponseSave ers in eventsReferencedByVariable)
{
iElement.Events.Remove(ers);
}
}
UpdateCurrentTreeNodeAndCodeAndSave(false);
UpdateAllDerivedElementFromBaseValues(false, true);
}