Opc.Ua.ConditionState.ProcessBeforeEnableDisable C# (CSharp) Method

ProcessBeforeEnableDisable() protected method

Does any processing before a condition is enabled or disabled.
protected ProcessBeforeEnableDisable ( ISystemContext context, bool enabling ) : ServiceResult
context ISystemContext The system context.
enabling bool True is the condition is being enabled.
return ServiceResult
        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;
        }