composeRecord static method

DC composeRecord(
  1. IRecord record,
  2. DistributedConnection connection, [
  3. bool includeClassId = true,
  4. bool prependLength = false,
])

Implementation

static DC composeRecord(IRecord record, DistributedConnection connection,
    [bool includeClassId = true, bool prependLength = false]) {
  var rt = new BinaryList();

  var template = Warehouse.getTemplateByType(record.runtimeType);

  if (includeClassId) rt.addGuid(template.classId);

  var kv = record.serialize();

  template.properties.forEach((pt) {
    var value = kv[pt.name];
    rt.addDC(compose(value, connection));

    // @TODO: serialize
    // var value = pt.propertyInfo.GetValue(record, null);
    // rt.addDC(compose(value, connection));
  });

  if (prependLength) rt.insertInt32(0, rt.length);

  return rt.toDC();
}