Example #1
0
        public static DbcSchema Load(Stream source, int specifiedColumns)
        {
            XDocument doc    = XDocument.Load(source);
            DbcSchema result = new DbcSchema();

            foreach (var e in doc.Root.Elements("Column"))
            {
                var col = new DbcColumnSchema()
                {
                    Position = int.Parse(e.Attribute("Position").Value),
                    Name     = e.Attribute("Name").Value,
                    Type     = (ColumnType)Enum.Parse(typeof(ColumnType), e.Attribute("Type").Value, true),
                    Width    = int.Parse(e.Attribute("Width").Value)
                };

                result.AddColumn(col);
            }

            while (result.ColumnCount > specifiedColumns)
            {
                result.columns.RemoveAt(result.ColumnCount - 1);
            }

            while (result.columns.Count < specifiedColumns)
            {
                var col = new DbcColumnSchema()
                {
                    Position = result.ColumnCount,
                    Name     = "Column" + result.ColumnCount,
                    Type     = ColumnType.Int32,
                    Width    = 100,
                };

                result.AddColumn(col);
            }

            return(result);
        }
Example #2
0
 public void AddColumn(DbcColumnSchema column)
 {
     columns.Add(column);
 }