Create() публичный статический Метод

Creates a new XValue instance.
public static Create ( string content ) : XValue
content string The value content.
Результат XValue
Пример #1
0
 /// <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
        /// <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);
        }