Exemple #1
0
        private List <TableColumnExtended> BuildColumns(IEnumerable <DataRow> dataRows, out List <ColumnType> columnTypes)
        {
            var headers = new List <TableColumnExtended>();

            columnTypes = new List <ColumnType>();
            foreach (DataColumn dataColumn in dataRows.ElementAt(0).Table.Columns)
            {
                var formatter   = new ColumnPropertiesFormatter();
                var tableColumn = new TableColumnExtended();
                var headerCell  = new TableCellExtended()
                {
                };
                switch (style)
                {
                case EngineStyle.ByIndex:
                    headerCell.Text = string.Format("#{0} ({1})", headers.Count, dataColumn.ColumnName);
                    break;

                case EngineStyle.ByName:
                    headerCell.Text = string.Format("{0}", dataColumn.ColumnName);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                tableColumn.HeaderCell = headerCell;

                if (dataColumn.ExtendedProperties.Count > 0)
                {
                    var role      = (ColumnRole)(dataColumn.ExtendedProperties["NBi::Role"] ?? ColumnRole.Key);
                    var type      = (ColumnType)(dataColumn.ExtendedProperties["NBi::Type"] ?? ColumnType.Text);
                    var tolerance = (Tolerance)(dataColumn.ExtendedProperties["NBi::Tolerance"]);
                    var rounding  = (Rounding)(dataColumn.ExtendedProperties["NBi::Rounding"]);
                    columnTypes.Add(type);

                    var subHeader     = formatter.GetText(role, type, tolerance, rounding);
                    var subHeaderCell = new TableCellExtended()
                    {
                        Text = subHeader
                    };
                    tableColumn.SubHeaderCell = subHeaderCell;
                }
                else
                {
                    columnTypes.Add(ColumnType.Text);
                }

                headers.Add(tableColumn);
            }

            return(headers);
        }
Exemple #2
0
        protected IEnumerable <TableColumnExtended> RenderColumns(IEnumerable <ExtendedMetadata> metadatas)
        {
            var formatter = new ColumnPropertiesFormatter();

            foreach (var metadata in metadatas)
            {
                var tableColumn = new TableColumnExtended()
                {
                    HeaderCell = new TableCellExtended()
                    {
                        Text = (metadata.Identifier) == null ? $"#{metadata.Ordinal} ({metadata.Name})" : $"{metadata.Identifier.Label}"
                    },
                    SubHeaderCell = new TableCellExtended()
                    {
                        Text = formatter.GetText(metadata)
                    }
                };
                yield return(tableColumn);
            }
        }