Database column.
Inheritance: ObservableObject
Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="XDatabase"/> instance.
        /// </summary>
        /// <param name="name">The database name.</param>
        /// <param name="fields">The fields collection.</param>
        /// <param name="idColumnName">The Id column name.</param>
        /// <returns>The new instance of the <see cref="XDatabase"/> class.</returns>
        public static XDatabase FromFields(string name, IEnumerable <string[]> fields, string idColumnName = DefaultIdColumnName)
        {
            var db          = XDatabase.Create(name, idColumnName);
            var tempColumns = fields.FirstOrDefault().Select(c => XColumn.Create(db, c));
            var columns     = ImmutableArray.CreateRange <XColumn>(tempColumns);

            if (columns.Length >= 1 && columns[0].Name == idColumnName)
            {
                // Use existing record Id.
                var tempRecords = fields
                                  .Skip(1)
                                  .Select(v =>
                                          XRecord.Create(
                                              db,
                                              v.FirstOrDefault(),
                                              columns,
                                              ImmutableArray.CreateRange <XValue>(v.Select(c => XValue.Create(c)))));
                var records = ImmutableArray.CreateRange <XRecord>(tempRecords);

                db.Columns = columns;
                db.Records = records;
            }
            else
            {
                // Create records with new Id.
                var tempRecords = fields
                                  .Skip(1)
                                  .Select(v =>
                                          XRecord.Create(
                                              db,
                                              columns,
                                              ImmutableArray.CreateRange <XValue>(v.Select(c => XValue.Create(c)))));
                var records = ImmutableArray.CreateRange <XRecord>(tempRecords);

                db.Columns = columns;
                db.Records = records;
            }

            return(db);
        }
Beispiel #2
0
        private void Remove(XColumn column)
        {
            if (column == null)
                return;

            column.PropertyChanged -= ObserveColumn;
        }
Beispiel #3
0
        private void Add(XColumn column)
        {
            if (column == null)
                return;

            column.PropertyChanged += ObserveColumn;
        }
Beispiel #4
0
 public void Inherits_From_ObservableObject()
 {
     var target = new XColumn();
     Assert.True(target is ObservableObject);
 }