private void ToJson(JsonWriter writer, Row row, JsonSerializer serializer) { writer.WriteStartObject(); if (row.TrackAssignments) { var modified = row.assignedFields; if (modified != null) { var fields = row.fields; for (var i = 0; i < fields.Count; i++) if (modified[i]) { var f = fields[i]; if (!f.IsNull(row)) { writer.WritePropertyName(f.PropertyName ?? f.Name); f.ValueToJson(writer, row, serializer); } } } } else { var fields = row.fields; foreach (var f in fields) if (!f.IsNull(row)) { writer.WritePropertyName(f.PropertyName ?? f.Name); f.ValueToJson(writer, row, serializer); } } writer.WriteEndObject(); }
public void BeginEdit() { TrackAssignments = true; if (originalValues == null) originalValues = this.CloneRow(); }
public static List<PropertyItem> GetCustomFieldPropertyItems(IEnumerable<ICustomFieldDefinition> definitions, Row row, string fieldPrefix) { var list = new List<PropertyItem>(); foreach (var def in definitions) { var name = fieldPrefix + def.Name; var field = row.FindFieldByPropertyName(name) ?? row.FindField(name); list.Add(GetCustomFieldPropertyItem(def, field)); } return list; }
public void CloneInto(Row clone, bool cloneHandlers) { clone.ignoreConstraints = ignoreConstraints; foreach (var field in GetFields()) field.Copy(this, clone); clone.tracking = tracking; if (tracking) { if (assignedFields != null) { clone.assignedFields = new bool[assignedFields.Length]; Array.Copy(assignedFields, clone.assignedFields, assignedFields.Length); } } else clone.assignedFields = null; clone.trackWithChecks = trackWithChecks; clone.originalValues = originalValues; if (dictionaryData != null) clone.dictionaryData = (Hashtable)this.dictionaryData.Clone(); else clone.dictionaryData = null; if (indexedData != null) { clone.indexedData = new object[indexedData.Length]; for (var i = 0; i < indexedData.Length; i++) clone.indexedData[i] = indexedData[i]; } else clone.indexedData = null; if (previousValues != null) clone.previousValues = previousValues.CloneRow(); else clone.previousValues = null; if (cloneHandlers) { clone.postHandler = this.postHandler; clone.propertyChanged = this.propertyChanged; if (this.validationErrors != null) clone.validationErrors = new Dictionary<string, string>(this.validationErrors); else clone.validationErrors = null; } }
public void CancelEdit() { if (originalValues != null) { var original = originalValues; originalValues = null; for (var i = 0; i < fields.Count; i++) fields[i].CopyNoAssignment(original, this); assignedFields = original.assignedFields; ClearValidationErrors(); } }
private static void AddInstance(Dictionary<string, Dictionary<string, Row>> registry, Row row) { try { var connectionKey = GetConnectionKey(row.GetType()); Dictionary<string, Row> connectionRegistry; if (!registry.TryGetValue(connectionKey, out connectionRegistry)) registry[connectionKey] = connectionRegistry = new Dictionary<string, Row>(StringComparer.OrdinalIgnoreCase); var table = row.Table; connectionRegistry.Add(table, row); } catch (Exception ex) { new InvalidOperationException(String.Format("Can't register Row instance in DataSchema: {0}", row.GetType().FullName), ex).Log(); } }
public RowValidationContext(IDbConnection connection, Row row) { this.row = row; this.Connection = connection; }
protected void CheckUnassignedRead(Row row) { if (row == null) throw new ArgumentNullException("row"); if (!row.tracking) return; if (!row.trackWithChecks) return; if (row.IsAssigned(this)) return; if (!this.GetIsNull(row)) return; throw new InvalidOperationException(String.Format( "{0} field on {1} is read before assigned a value!", this.Name, row.GetType().Name)); }
public abstract void AsObject(Row row, object value);
public abstract object AsObject(Row row);
public abstract int IndexCompare(Row row1, Row row2);
public abstract void GetFromReader(IDataReader reader, int index, Row row);
public abstract void Copy(Row source, Row target);
public abstract void ValueFromJson(JsonReader reader, Row row, JsonSerializer serializer);
public abstract void ValueToJson(JsonWriter writer, Row row, JsonSerializer serializer);
public void EndEdit() { if (postHandler != null && originalValues != null) { if (insidePostHandler > 0) return; // exception daha iyi olabilir mi? insidePostHandler++; try { ClearValidationErrors(); postHandler(this); if (HasErrors) throw new Exception("Lütfen satırdaki işaretli alanları düzeltiniz."); originalValues = null; } finally { insidePostHandler--; } if (PostEnded != null) PostEnded(this, new EventArgs()); } else { originalValues = null; ClearValidationErrors(); } }
public static string GetConnectionKey(Row row) { return GetConnectionKey(row.GetType()); }
protected abstract bool GetIsNull(Row row);
public bool IsNull(Row row) { CheckUnassignedRead(row); return GetIsNull(row); }
public void CopyNoAssignment(Row source, Row target) { Copy(source, target); target.ClearAssignment(this); }