//--------------------------------------------------------------------------------------------/ // CTOR //--------------------------------------------------------------------------------------------/ /// <summary> /// Only draws the field if the condition is met /// </summary> /// <param name="memberName">The name of the property that is being compared</param> /// <param name="comparedValue">The value the property is being compared to</param> /// <param name="comparison">The predicate to use</param> /// <param name="default">What should happen if the condition is not met</param> public DrawIfAttribute(string memberName, object comparedValue, ComparisonType comparison, PropertyDrawingType defaultBehavior = PropertyDrawingType.DontDraw) { this.comparedMemberName = memberName; this.predicate = PredicateMode.PropertyComparison; this.comparedValue = comparedValue; this.comparison = comparison; this.defaultBehavior = defaultBehavior; }
/// <summary> /// Only draws the field if the boolean member is true /// </summary> public DrawIfAttribute(string memberName, PropertyDrawingType defaultBehavior = PropertyDrawingType.DontDraw) { this.comparedMemberName = memberName; this.predicate = PredicateMode.Predicate; this.comparison = ComparisonType.Equals; this.comparedValue = true; this.defaultBehavior = defaultBehavior; }
/// <summary> /// Only draws the field if the condition is met /// </summary> /// <param name="comparedPropertyName">The name of the property that is being compared</param> /// <param name="comparedValue">The value the property is being compared to</param> /// <param name="comparison">The predicate to use</param> /// <param name="default">What should happen if the condition is not met</param> public DrawIfAttribute(string predicateFunctionName, PropertyDrawingType defaultBehavior = PropertyDrawingType.DontDraw) { this.predicate = PredicateMode.Predicate; this.predicateName = predicateFunctionName; //this.type = type; // //this.predicateMethod = type.GetMethod(predicateName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); //if (this.predicateMethod != null) // isProperty = false; // //this.predicateProperty = type.GetProperty(predicateName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty); //if (this.predicateProperty != null) // isProperty = true; // //if (predicateMethod == null && predicateProperty == null) // throw new System.Exception($"The predicate method or property {predicateName} is missing!"); this.defaultBehavior = defaultBehavior; }