Example #1
0
            }     //end constructor

            public bool AddDerivedData(data_item data, int ordinal)
            {
                foreach (column c in this.items)
                {
                    //we cant update an ordinal that already exists...
                    if (c.index == ordinal)
                    {
                        return(false);
                    }
                }

                //ok we got herer, the column doesnt exist. lets add it.
                column new_data_column = new column(data.value, this.config, ordinal);

                this.items.Add(new_data_column);

                return(true);
            }
Example #2
0
            public column(string data, table_config config, int index)
            {
                this.index  = index;
                this.config = config;
                //this.items = new items();
                string[] column_elements = data.Split(config.array_delimiter);

                //loop through the elements
                int element_index            = 0;
                column_definition column_def = config.columns.get_column_by_ordinal(index);

                if (column_def == null)
                {
                    // if we have no column. its because it wasnt defined. so add a default name based on index
                    // then set it to derived and arry type, the least restrictive
                    bool new_col_results = config.columns.Add("COLUMN_" + index, index, index, 2, true);
                    if (false == new_col_results)
                    {
                        //error
                    }

                    column_def = config.columns.get_column_by_ordinal(index);
                    if (column_def == null)
                    {
                        //cant add it at all error
                    }
                }
                if (column_def.type == 1 && column_elements.Length > 1)
                {
                    this.error = true;
                }

                foreach (string element in column_elements)
                {
                    //process the data_item
                    data_item new_item = new data_item(element, config, element_index);
                    items.Add(new_item);
                    if (new_item.error == true)
                    {
                        this.error = true;
                    }
                } //end elements loop
            }