/// <summary> /// Tests if the data in <paramref name="data"/> can be used for the DecomposeByColumnContent action. /// </summary> /// <param name="data">The data to test.</param> /// <param name="throwIfNonCoherent">If true, an exception is thrown if any problems are detected. If false, it is tried to rectify the problem by making some assumtions.</param> public static void EnsureCoherence(DataTableMultipleColumnProxy data, bool throwIfNonCoherent) { if (null == data.DataTable) // this is mandatory, thus an exception is always thrown { throw new ArgumentNullException("SourceTable is null, it must be set before"); } data.EnsureExistenceOfIdentifier(ColumnX, 1); data.EnsureExistenceOfIdentifier(ColumnY, 1); data.EnsureExistenceOfIdentifier(ColumnV, 1); if (data.GetDataColumns(ColumnV).Count == 0) { if (throwIfNonCoherent) { throw new ArgumentException(!data.ContainsIdentifier(ColumnV) ? "ColumnsToProcess is not set" : "ColumnsToProcess is empty"); } } if (data.GetDataColumnOrNull(ColumnX) == null) { if (throwIfNonCoherent) { throw new ArgumentException("X column not included in columnsToProcess"); } else { var col = data.GetDataColumns(ColumnV).FirstOrDefault(); if (null != col) { data.SetDataColumn(ColumnX, col); } } } if (data.GetDataColumnOrNull(ColumnY) == null) { if (throwIfNonCoherent) { throw new ArgumentException("Y column not included in columnsToProcess"); } else { var col = data.GetDataColumns(ColumnV).FirstOrDefault(); if (null != col) { data.SetDataColumn(ColumnY, col); } } } }
/// <summary> /// Tests if the data in <paramref name="data"/> can be used for the ExpandCyclingVariable action. /// </summary> /// <param name="data">The data to test.</param> /// <param name="throwIfNonCoherent">If true, an exception is thrown if any problems are detected. If false, it is tried to rectify the problem by making some assumtions.</param> public static void EnsureCoherence(DataTableMultipleColumnProxy data, bool throwIfNonCoherent) { if (null == data.DataTable) // this is mandatory, thus an exception is always thrown { throw new ArgumentNullException("SourceTable is null, it must be set before"); } data.EnsureExistenceOfIdentifier(ColumnsParticipatingIdentifier); data.EnsureExistenceOfIdentifier(ColumnWithCyclingVariableIdentifier, 1); data.EnsureExistenceOfIdentifier(ColumnsToAverageIdentifier); if (data.GetDataColumns(ColumnsParticipatingIdentifier).Count == 0) { if (throwIfNonCoherent) { throw new ArgumentException(!data.ContainsIdentifier(ColumnsParticipatingIdentifier) ? "ColumnsToProcess is not set" : "ColumnsToProcess is empty"); } } if (data.GetDataColumnOrNull(ColumnWithCyclingVariableIdentifier) == null) { if (throwIfNonCoherent) { throw new ArgumentException("Column with cycling variable was not included in columnsToProcess"); } else { var col = data.GetDataColumns(ColumnsParticipatingIdentifier).FirstOrDefault(); if (null != col) { data.SetDataColumn(ColumnWithCyclingVariableIdentifier, col); } } } if (!data.ContainsIdentifier(ColumnsToAverageIdentifier)) { if (throwIfNonCoherent) { throw new ArgumentException("ColumnsToAverage collection is not included"); } } }
/// <summary> /// Tests if the data in <paramref name="data"/> can be used for the DecomposeByColumnContent action. /// </summary> /// <param name="data">The data to test.</param> /// <param name="throwIfNonCoherent">If true, an exception is thrown if any problems are detected. If false, it is tried to rectify the problem by making some assumtions.</param> public static void EnsureCoherence(DataTableMultipleColumnProxy data, bool throwIfNonCoherent) { if (null == data.DataTable) // this is mandatory, thus an exception is always thrown { throw new ArgumentNullException("SourceTable is null, it must be set before"); } data.EnsureExistenceOfIdentifier(ColumnsParticipatingIdentifier); data.EnsureExistenceOfIdentifier(ColumnWithCyclingVariableIdentifier, 1); if (data.GetDataColumns(ColumnsParticipatingIdentifier).Count == 0) { if (throwIfNonCoherent) throw new ArgumentException(!data.ContainsIdentifier(ColumnsParticipatingIdentifier) ? "ColumnsToProcess is not set" : "ColumnsToProcess is empty"); } if (data.GetDataColumnOrNull(ColumnWithCyclingVariableIdentifier) == null) { if (throwIfNonCoherent) throw new ArgumentException("Column with cycling variable was not included in columnsToProcess"); else { var col = data.GetDataColumns(ColumnsParticipatingIdentifier).FirstOrDefault(); if (null != col) data.SetDataColumn(ColumnWithCyclingVariableIdentifier, col); } } }