protected virtual ServiceResult ProcessBeforeEnableDisable(ISystemContext context, bool enabling)
{
if (enabling && this.EnabledState.Id.Value)
{
return StatusCodes.BadConditionAlreadyEnabled;
}
if (!enabling && !this.EnabledState.Id.Value)
{
return StatusCodes.BadConditionAlreadyDisabled;
}
if (OnEnableDisable != null)
{
try
{
return OnEnableDisable(context, this, enabling);
}
catch (Exception e)
{
return ServiceResult.Create(e, StatusCodes.BadUnexpectedError, "Unexpected error enabling or disabling a Condition.");
}
}
return ServiceResult.Good;
}