diff --git a/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs b/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs index 17da8af4..1da0b1f0 100644 --- a/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs +++ b/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs @@ -36,14 +36,20 @@ public ResolveSet Resolve(Document context, string target, ParameterInfo[] param nameof(TableSectionData.CanInsertRow) => ResolveCanInsertRow(), nameof(TableSectionData.CanRemoveColumn) => ResolveCanRemoveColumn(), nameof(TableSectionData.CanRemoveRow) => ResolveCanRemoveRow(), - nameof(TableSectionData.GetCellCalculatedValue) => ResolveCellCalculatedValue(), - nameof(TableSectionData.GetCellCategoryId) => ResolveCellCategoryId(), - nameof(TableSectionData.GetCellCombinedParameters) => ResolveCellCombinedParameters(), - nameof(TableSectionData.GetCellFormatOptions) => ResolveCellFormatOptions(), - nameof(TableSectionData.GetCellParamId) => ResolveCellParamId(), + nameof(TableSectionData.GetCellCalculatedValue) when parameters.Length == 1 => ResolveCellCalculatedValueForColumns(), + nameof(TableSectionData.GetCellCalculatedValue) when parameters.Length == 2 => ResolveCellCalculatedValueForTable(), + nameof(TableSectionData.GetCellCategoryId) when parameters.Length == 1 => ResolveCellCategoryIdForColumns(), + nameof(TableSectionData.GetCellCategoryId) when parameters.Length == 2 => ResolveCellCategoryIdForTable(), + nameof(TableSectionData.GetCellCombinedParameters) when parameters.Length == 1 => ResolveCellCombinedParametersForColumns(), + nameof(TableSectionData.GetCellCombinedParameters) when parameters.Length == 2 => ResolveCellCombinedParametersForTable(), + nameof(TableSectionData.GetCellFormatOptions) when parameters.Length == 2 => ResolveCellFormatOptionsForColumns(), + nameof(TableSectionData.GetCellFormatOptions) when parameters.Length == 3 => ResolveCellFormatOptionsForTable(), + nameof(TableSectionData.GetCellParamId) when parameters.Length == 1 => ResolveCellParamIdForColumns(), + nameof(TableSectionData.GetCellParamId) when parameters.Length == 2 => ResolveCellParamIdForTable(), nameof(TableSectionData.GetCellSpec) => ResolveCellSpec(), nameof(TableSectionData.GetCellText) => ResolveCellText(), - nameof(TableSectionData.GetCellType) => ResolveCellType(), + nameof(TableSectionData.GetCellType) when parameters.Length == 1 => ResolveCellTypeForColumns(), + nameof(TableSectionData.GetCellType) when parameters.Length == 2 => ResolveCellTypeForTable(), nameof(TableSectionData.GetRowHeight) => ResolveRowHeight(), nameof(TableSectionData.RefreshData) => ResolveSet.Append(false, "Overridden"), _ => null @@ -69,8 +75,8 @@ ResolveSet ResolveOverrideCellStyle() ResolveSet ResolveCanInsertColumn() { var count = tableSectionData.NumberOfColumns; - var resolveSummary = new ResolveSet(count + 2); - for (var i = 0; i < count + 2; i++) + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) { var result = tableSectionData.CanInsertColumn(i); resolveSummary.AppendVariant(result, $"{i}: {result}"); @@ -82,8 +88,8 @@ ResolveSet ResolveCanInsertColumn() ResolveSet ResolveCanInsertRow() { var count = tableSectionData.NumberOfRows; - var resolveSummary = new ResolveSet(count + 2); - for (var i = 0; i < count + 2; i++) + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) { var result = tableSectionData.CanInsertRow(i); resolveSummary.AppendVariant(result, $"{i}: {result}"); @@ -118,7 +124,20 @@ ResolveSet ResolveCanRemoveRow() return resolveSummary; } - ResolveSet ResolveCellCalculatedValue() + ResolveSet ResolveCellCalculatedValueForColumns() + { + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(columnsNumber); + for (var j = 0; j < columnsNumber; j++) + { + var result = tableSectionData.GetCellCalculatedValue(j); + resolveSummary.AppendVariant(result, $"Column {j}: {result}"); + } + + return resolveSummary; + } + + ResolveSet ResolveCellCalculatedValueForTable() { var rowsNumber = tableSectionData.NumberOfRows; var columnsNumber = tableSectionData.NumberOfColumns; @@ -135,23 +154,33 @@ ResolveSet ResolveCellCalculatedValue() return resolveSummary; } - ResolveSet ResolveCellCategoryId() + ResolveSet ResolveCellCategoryIdForColumns() { - var rowsNumber = tableSectionData.NumberOfRows; var columnsNumber = tableSectionData.NumberOfColumns; - var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + var resolveSummary = new ResolveSet(columnsNumber); for (var i = 0; i < columnsNumber; i++) { - var columnResult = tableSectionData.GetCellCategoryId(i); - if (columnResult != ElementId.InvalidElementId) + var result = tableSectionData.GetCellCategoryId(i); + if (result != ElementId.InvalidElementId) { - var category = Category.GetCategory(context, columnResult); + var category = Category.GetCategory(context, result); if (category is not null) { - resolveSummary.AppendVariant(columnResult, $"Column {i}: {category.Name}"); + resolveSummary.AppendVariant(result, $"Column {i}: {category.Name}"); } } - + } + + return resolveSummary; + } + + ResolveSet ResolveCellCategoryIdForTable() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { for (var j = 0; j < rowsNumber; j++) { var result = tableSectionData.GetCellCategoryId(j, i); @@ -169,15 +198,26 @@ ResolveSet ResolveCellCategoryId() return resolveSummary; } - ResolveSet ResolveCellCombinedParameters() + ResolveSet ResolveCellCombinedParametersForColumns() + { + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + var result = tableSectionData.GetCellCombinedParameters(i); + resolveSummary.AppendVariant(result, $"Column {i}"); + } + + return resolveSummary; + } + + ResolveSet ResolveCellCombinedParametersForTable() { var rowsNumber = tableSectionData.NumberOfRows; var columnsNumber = tableSectionData.NumberOfColumns; var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); for (var i = 0; i < columnsNumber; i++) { - var columnResult = tableSectionData.GetCellCombinedParameters(i); - resolveSummary.AppendVariant(columnResult, $"Column {i}"); for (var j = 0; j < rowsNumber; j++) { var result = tableSectionData.GetCellCombinedParameters(j, i); @@ -188,15 +228,26 @@ ResolveSet ResolveCellCombinedParameters() return resolveSummary; } - ResolveSet ResolveCellFormatOptions() + ResolveSet ResolveCellFormatOptionsForColumns() + { + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + var result = tableSectionData.GetCellFormatOptions(i, context); + resolveSummary.AppendVariant(result, $"Column {i}"); + } + + return resolveSummary; + } + + ResolveSet ResolveCellFormatOptionsForTable() { var rowsNumber = tableSectionData.NumberOfRows; var columnsNumber = tableSectionData.NumberOfColumns; var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); for (var i = 0; i < columnsNumber; i++) { - var columnResult = tableSectionData.GetCellFormatOptions(i, context); - resolveSummary.AppendVariant(columnResult, $"Column {i}"); for (var j = 0; j < rowsNumber; j++) { var result = tableSectionData.GetCellFormatOptions(j, i, context); @@ -207,20 +258,30 @@ ResolveSet ResolveCellFormatOptions() return resolveSummary; } - ResolveSet ResolveCellParamId() + ResolveSet ResolveCellParamIdForColumns() { - var rowsNumber = tableSectionData.NumberOfRows; var columnsNumber = tableSectionData.NumberOfColumns; - var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + var resolveSummary = new ResolveSet(columnsNumber); for (var i = 0; i < columnsNumber; i++) { - var columnResult = tableSectionData.GetCellParamId(i); - if (columnResult != ElementId.InvalidElementId) + var result = tableSectionData.GetCellParamId(i); + if (result != ElementId.InvalidElementId) { - var parameter = columnResult.ToElement(context); - resolveSummary.AppendVariant(columnResult, $"Column {i}: {parameter!.Name}"); + var parameter = result.ToElement(context); + resolveSummary.AppendVariant(result, $"Column {i}: {parameter!.Name}"); } - + } + + return resolveSummary; + } + + ResolveSet ResolveCellParamIdForTable() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { for (var j = 0; j < rowsNumber; j++) { var result = tableSectionData.GetCellParamId(j, i); @@ -246,7 +307,7 @@ ResolveSet ResolveCellSpec() { var result = tableSectionData.GetCellSpec(j, i); if (!result.Empty()) - resolveSummary.AppendVariant(result, $"Row {j}, Column {i}: {result.ToLabel()}"); + resolveSummary.AppendVariant(result, $"Row {j}, Column {i}: {result.ToUnitLabel()}"); } } @@ -270,15 +331,26 @@ ResolveSet ResolveCellText() return resolveSummary; } - ResolveSet ResolveCellType() + ResolveSet ResolveCellTypeForColumns() { - var rowsNumber = tableSectionData.NumberOfRows; var columnsNumber = tableSectionData.NumberOfColumns; - var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + var resolveSummary = new ResolveSet(columnsNumber); for (var i = 0; i < columnsNumber; i++) { var columnResult = tableSectionData.GetCellType(i); resolveSummary.AppendVariant(columnResult, $"Column {i}: {columnResult}"); + } + + return resolveSummary; + } + + ResolveSet ResolveCellTypeForTable() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { for (var j = 0; j < rowsNumber; j++) { var result = tableSectionData.GetCellType(j, i);