Record value.
상속: ObservableObject
예제 #1
0
파일: XRecord.cs 프로젝트: nagyistge/Core2D
 /// <summary>
 /// Creates a new <see cref="XRecord"/> instance.
 /// </summary>
 /// <param name="owner">The record owner.</param>
 /// <param name="value">The record value.</param>
 /// <returns>The new instance of the <see cref="XRecord"/> class.</returns>
 public static XRecord Create(XDatabase owner, string value)
 {
     return(new XRecord()
     {
         Id = Guid.NewGuid(),
         Columns = owner.Columns,
         Values = ImmutableArray.CreateRange(
             Enumerable.Repeat(
                 value,
                 owner.Columns.Length).Select(c => XValue.Create(c))),
         Owner = owner
     });
 }
예제 #2
0
        private void Remove(XValue value)
        {
            if (value == null)
                return;

            value.PropertyChanged -= ObserveValue;
        }
예제 #3
0
        private void Add(XValue value)
        {
            if (value == null)
                return;

            value.PropertyChanged += ObserveValue;
        }
예제 #4
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);
        }
예제 #5
0
 public void Inherits_From_ObservableObject()
 {
     var target = new XValue();
     Assert.True(target is ObservableObject);
 }