/// <summary> /// Find the effective (inherited) value of a column in a debt class. /// </summary> /// <typeparam name="T">The type of the column.</typeparam> /// <param name="debtClassId">The DebtClassId of the debt class in question.</param> /// <param name="field">The column to retrieve.</param> /// <returns>Effective value of the indicated column, eg. the value in the debt class with the indicated ID, or, if that debt class has no /// value for the column, the value of the column in nearest ancestor debt class that has a value for that column. If no value can be found, /// returns null.</returns> private static object FindEffectiveField <T>(Guid debtClassId, DataColumn field) { object value = null; lock (DataModel.SyncRoot) { DebtClassRow parent = DebtClass.FindParentWithField(debtClassId, field); if (parent != null) { value = (object)parent.Field <T>(field); } } return(value); }
/// <summary> /// Find the debt rule assocatiated with a debt class of a particular type. This function locks the DataModel. /// </summary> /// <param name="debtClassId">The DebtClassId of the debt class.</param> /// <param name="typeId">The TypeId of the debt class.</param> /// <returns>The debt rule. If none can be found either in the debt class or its ancestors, null is returned.</returns> public static DebtRule GetDebtRule(Guid debtClassId, Guid typeId) { DebtRule rule = null; lock (DataModel.SyncRoot) { DebtClassRow parent = DebtClass.FindParentWithField(debtClassId, DataModel.DebtClass.DebtRuleIdColumn); if (parent != null) { rule = new DebtRule(parent.DebtRuleRow); } } return(rule); }