/// <summary> /// Maps versioned field values from a deserialized item to the FakeDb item. /// </summary> /// <param name="item">Deserialized item</param> /// <param name="dsDbItem">FakeDb item to copy values to</param> internal static void CopyVersionedFieldsTo(this SyncItem item, IDsDbItem dsDbItem) { var fields = new List <DbField>(); foreach (var version in item.Versions) { foreach (var field in version.Fields) { Assert.IsTrue(ID.IsID(field.FieldID), string.Format("Field id '{0}' is not a valid guid", field.FieldID)); var fieldId = ID.Parse(field.FieldID); var dbField = fields.FirstOrDefault(f => f.ID == fieldId); if (dbField == null) { dbField = new DbField(field.FieldName, fieldId) { Shared = false }; dsDbItem.Add(dbField); fields.Add(dbField); } int versionNumber; if (int.TryParse(version.Version, out versionNumber)) { dbField.Add(version.Language, versionNumber, field.FieldValue); } else { dbField.Add(version.Language, field.FieldValue); } } } }
public DsItemLoadingArgs(IDsDbItem dsDbItem, DataStorage dataStorage) { Assert.ArgumentNotNull(dsDbItem, "dsDbItem"); Assert.ArgumentNotNull(dataStorage, "dataStorage"); this.dsDbItem = dsDbItem; this.dataStorage = dataStorage; }
/// <summary> /// Maps shared field values from a deserialized item to the FakeDb item. /// </summary> /// <param name="item">Deserialized item</param> /// <param name="dsDbItem">FakeDb item to copy values to</param> internal static void CopySharedFieldsTo(this SyncItem item, IDsDbItem dsDbItem) { foreach (var sharedField in item.SharedFields) { Assert.IsTrue(ID.IsID(sharedField.FieldID), string.Format("Shared field id '{0}' is not a valid guid", sharedField.FieldID)); var field = dsDbItem.Fields.FirstOrDefault(f => f.ID.ToString() == sharedField.FieldID); if (field != null) { field.Value = sharedField.FieldValue; } else { dsDbItem.Add(new DbField(sharedField.FieldName, ID.Parse(sharedField.FieldID)) { Value = sharedField.FieldValue, Shared = true }); } } }
/// <summary> /// Maps versioned field values from a deserialized item to the FakeDb item. /// </summary> /// <param name="item">Deserialized item</param> /// <param name="dsDbItem">FakeDb item to copy values to</param> internal static void CopyVersionedFieldsTo(this SyncItem item, IDsDbItem dsDbItem) { var fields = new List<DbField>(); foreach (var version in item.Versions) { foreach (var field in version.Fields) { Assert.IsTrue(ID.IsID(field.FieldID), string.Format("Field id '{0}' is not a valid guid", field.FieldID)); var fieldId = ID.Parse(field.FieldID); var dbField = fields.FirstOrDefault(f => f.ID == fieldId); if (dbField == null) { dbField = new DbField(field.FieldName, fieldId) { Shared = false }; dsDbItem.Add(dbField); fields.Add(dbField); } int versionNumber; if (int.TryParse(version.Version, out versionNumber)) { dbField.Add(version.Language, versionNumber, field.FieldValue); } else { dbField.Add(version.Language, field.FieldValue); } } } }