Ejemplo n.º 1
0
        public static bool IsEnabled(Object target, MethodInfo method)
        {
            EnableIfAttributeBase enableIfAttribute = method.GetCustomAttribute <EnableIfAttributeBase>();

            if (enableIfAttribute == null)
            {
                return(true);
            }

            List <bool> conditionValues = PropertyUtility.GetConditionValues(target, enableIfAttribute.Conditions);

            if (conditionValues.Count > 0)
            {
                bool enabled = PropertyUtility.GetConditionsFlag(conditionValues, enableIfAttribute.ConditionOperator, enableIfAttribute.Inverted);
                return(enabled);
            }
            else
            {
                string message = enableIfAttribute.GetType().Name + " needs a valid boolean condition field, property or method name to work";
                Debug.LogWarning(message, target);

                return(false);
            }
        }