Esempio n. 1
0
 /// <inheritdoc/>
 public bool ShowInInspector([NotNull] Type containingClassType, [CanBeNull] object containingClassInstance, [CanBeNull] MemberInfo classMember)
 {
     if (evaluator == null)
     {
         evaluator = EvaluationUtility.GenerateEvaluatorForBooleanExpression(expression);
     }
     return(evaluator.Evaluate(containingClassType, containingClassInstance, classMember));
 }
Esempio n. 2
0
        public bool Evaluate([NotNull] Type containingClassType, [CanBeNull] object containingClassInstance, [CanBeNull] MemberInfo classMember)
        {
                        #if DEV_MODE
            Debug.Log("Expression.Evaluate left and right for " + containingClassType.Name + "/" + (classMember == null ? "null" : classMember.Name) + " with any=" + any);
                        #endif

            if (left.Evaluate(containingClassType, containingClassInstance, classMember))
            {
                if (any)
                {
                    return(true);
                }
                return(right.Evaluate(containingClassType, containingClassInstance, classMember));
            }
            if (any)
            {
                return(right.Evaluate(containingClassType, containingClassInstance, classMember));
            }
            return(false);
        }
Esempio n. 3
0
        public bool ShowInInspector([NotNull] Type containingClassType, [CanBeNull] object containingClassInstance, [CanBeNull] MemberInfo classMember)
        {
            if (alwaysShow)
            {
                return(true);
            }

            if (evaluatorExpression != null)
            {
                if (evaluator == null)
                {
                    evaluator = EvaluationUtility.GenerateEvaluatorForBooleanExpression(evaluatorExpression);
                }
                return(evaluator.Evaluate(containingClassType, containingClassInstance, classMember));
            }

            if (!string.IsNullOrEmpty(classMemberName))
            {
                var classMembers = containingClassType.GetMember(classMemberName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);

                int classMembersFound = classMembers.Length;

                if (classMembersFound == 0)
                {
                    Debug.LogError("HelpBoxAttribute class member by name \"" + classMemberName + "\" not found.");
                    return(true);
                }

                classMember = classMembers[0];
            }

            var    field = classMember as FieldInfo;
            object currentValue;
            Type   classMemberType;

            if (field is object)
            {
                classMemberType = field.FieldType;
                currentValue    = field.GetValue(field.IsStatic ? null : containingClassInstance);
            }
            else
            {
                var property = classMember as PropertyInfo;
                if (property is object)
                {
                    classMemberType = property.PropertyType;
                    var getAccessor = property.GetGetMethod();
                    currentValue = getAccessor.Invoke(getAccessor.IsStatic ? null : containingClassInstance, null);
                }
                else
                {
                    Debug.LogError("ShowInInspectorIfAttribute class member by name \"" + classMemberName + "\" was not a field or a property.");
                    return(true);
                }
            }

                        #if DEV_MODE
            Debug.Log("Show if \"" + classMemberName + "\" value (" + (currentValue == null ? "null" : currentValue.ToString()) + ") " + comparisonType + " " + (requiredValue == null ? "null" : requiredValue.ToString()));
                        #endif

            return(EvaluationUtility.Test(currentValue, comparisonType, requiredValue));
        }
Esempio n. 4
0
 public bool Evaluate([NotNull] Type containingClassType, [CanBeNull] object containingClassInstance, [CanBeNull] MemberInfo classMember)
 {
     return(!expressionToNegate.Evaluate(containingClassType, containingClassInstance, classMember));
 }