internal void SetModified(BaseProperty property, bool?value) { var col = property?.Column ?? -1; if (col >= 0 && col < Modified.Count) { Modified[col] = value; } }
internal void SetEditing(BaseProperty property, bool value) { var col = property?.Column ?? -1; if (col >= 0 && col < Editing.Length) { Editing[col] = value; } }
internal void SetEditable(BaseProperty property, bool?value) { var col = property?.Column ?? -1; if (col >= 0 && col < Editable.Count) { Editable[col] = value; } }
/// <summary> /// Stores specified change to the given property to listen to, /// or adds the change to the stored property, if one already exists. /// </summary> /// <param name="prop">The property to listen to.</param> /// <param name="change">The property change to listen to.</param> protected void AddPropertyChange(BaseProperty prop, PropertyChange change) { if (properties.ContainsKey(prop)) { properties[prop] = properties[prop] + change; } else { properties[prop] = change; } }
/// <summary> /// Constructs a new computed binding for updating property editability. /// </summary> /// <param name="property">The property to update based on the computed result.</param> /// <param name="expression">Lambda expression used to compute the result.</param> /// <param name="args">Arguments for the specified expression to use for evaluation.</param> public ComputedEditableBinding(BaseProperty property, LambdaExpression expression, params object[] args) : base(property, expression, args) { if (property == null) { throw new ArgumentException("Property cannot be null", nameof(property)); } if (expression.ReturnType != typeof(bool)) { throw new Exception("Supplied expression should return a bool."); } }
/// <summary> /// Constructs a new computed binding for the property using the specified expression and concrete arguments. /// </summary> /// <param name="property">The property to update based on the computed result.</param> /// <param name="expression">Lambda expression used to compute the result.</param> /// <param name="args">Arguments for the specified expression to use for evaluation.</param> public ComputedBinding(BaseProperty property, LambdaExpression expression, params object[] args) { this.property = property; compiledExpression = expression.Compile(); IEnumerable <ParameterExpression> parameters = expression.Parameters; // last parameter can be dynamic data row not provided in the args if (parameters.Count() == args.Length + 1 && parameters.Last().Type == typeof(DataRow)) { rowArg = parameters.Last().Name; parameters = parameters.Take(parameters.Count() - 1); } if (parameters.Count() != args.Length) { throw new ArgumentException($"The number of arguments should match the number of expression parameters", nameof(args)); } for (int i = 0; i < args.Length; i++) { namedArgs[expression.Parameters[i].Name] = args[i]; } Visit(expression); foreach (var p in properties.Keys) { // subscribe to both sync and async, so that we could update using appropriate mode based on IsAsyc of the event p.Change += Recompute; p.AsyncChange += RecomputeAsync; } foreach (var o in objects.Keys) { o.PropertyChanged += Recompute; } foreach (var s in selectionLists) { s.SelectionChanged += RecomputeOnSelection; } }
/// <summary> /// Allows controlling property editability on the data object level. /// Subclasses can override this method to define custom rules /// for property editability. /// </summary> /// <param name="p">The property to check the editability of.</param> /// <returns>True if the property should be editable, false otherwise.</returns> public virtual bool IsPropertyEditable(BaseProperty p) { return(Editable && (parent == null || parent.IsPropertyEditable(p))); }
/// <summary> /// Allows controlling property visibility on the data object level. /// </summary> /// <param name="p">The property to check the visibility of.</param> /// <returns>True if the property should be visible, false otherwise.</returns> public virtual bool IsPropertyVisible(BaseProperty p) { return(parent == null || parent.IsPropertyVisible(p)); }
/// <summary> /// Allows controlling if the property is required on the data object level. /// </summary> /// <param name="p">The property being checked if it's required.</param> /// <returns>True if the property should be required, false otherwise.</returns> public virtual bool IsPropertyRequired(BaseProperty p) { return(parent == null || parent.IsPropertyRequired(p)); }
/// <summary> /// Allows controlling property visibility on the data object level. /// </summary> /// <param name="p">The property to check the visibility of.</param> /// <returns>True if the property should be visible, false otherwise.</returns> public virtual bool IsPropertyVisible(BaseProperty p) { return parent == null || parent.IsPropertyVisible(p); }
/// <summary> /// Allows controlling if the property is required on the data object level. /// </summary> /// <param name="p">The property being checked if it's required.</param> /// <returns>True if the property should be required, false otherwise.</returns> public virtual bool IsPropertyRequired(BaseProperty p) { return parent == null || parent.IsPropertyRequired(p); }
/// <summary> /// Allows controlling property editability on the data object level. /// Subclasses can override this method to define custom rules /// for property editability. /// </summary> /// <param name="p">The property to check the editability of.</param> /// <returns>True if the property should be editable, false otherwise.</returns> public virtual bool IsPropertyEditable(BaseProperty p) { return Editable && (parent == null || parent.IsPropertyEditable(p)); }
internal bool?GetModified(BaseProperty property) { var col = property?.Column ?? -1; return(col >= 0 && col < Modified.Count ? Modified[col] : null); }
internal bool GetEditing(BaseProperty property) { var col = property?.Column ?? -1; return(col >= 0 && col < Editing.Length && Editing[col]); }
internal bool?GetEditable(BaseProperty property) { var col = property?.Column ?? -1; return(col >= 0 && col < Editable.Count ? Editable[col] : null); }