Ejemplo n.º 1
0
        private void AddTupleDefaultly(IntermediateTuple tuple, Output output)
        {
            if (!this.TableDefinitions.TryGet(tuple.Definition.Name, out var tableDefinition))
            {
                return;
            }

            var table = output.EnsureTable(tableDefinition);
            var row   = table.CreateRow(tuple.SourceLineNumbers);

            for (var i = 0; i < tuple.Fields.Length; ++i)
            {
                if (i < tableDefinition.Columns.Length)
                {
                    var column = tableDefinition.Columns[i];

                    switch (column.Type)
                    {
                    case ColumnType.Number:
                        row[i] = tuple.AsNumber(i);
                        break;

                    default:
                        row[i] = tuple.AsString(i);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public bool TryAddTupleToOutputMatchingTableDefinitions(IntermediateTuple tuple, Output output, TableDefinition[] tableDefinitions)
        {
            var tableDefinition = tableDefinitions.FirstOrDefault(t => t.Name == tuple.Definition.Name);

            if (tableDefinition == null)
            {
                return(false);
            }

            var table = output.EnsureTable(tableDefinition);
            var row   = table.CreateRow(tuple.SourceLineNumbers);

            for (var i = 0; i < tuple.Fields.Length; ++i)
            {
                if (i < tableDefinition.Columns.Length)
                {
                    var column = tableDefinition.Columns[i];

                    switch (column.Type)
                    {
                    case ColumnType.Number:
                        row[i] = tuple.AsNumber(i);
                        break;

                    default:
                        row[i] = tuple.AsString(i);
                        break;
                    }
                }
            }

            return(true);
        }