Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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;
 }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
0
        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();
            }
        }
Exemplo n.º 7
0
 public RowValidationContext(IDbConnection connection, Row row)
 {
     this.row = row;
     this.Connection = connection;
 }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
 public abstract void AsObject(Row row, object value);
Exemplo n.º 10
0
 public abstract object AsObject(Row row);
Exemplo n.º 11
0
 public abstract int IndexCompare(Row row1, Row row2);
Exemplo n.º 12
0
 public abstract void GetFromReader(IDataReader reader, int index, Row row);
Exemplo n.º 13
0
 public abstract void Copy(Row source, Row target);
Exemplo n.º 14
0
 public abstract void ValueFromJson(JsonReader reader, Row row, JsonSerializer serializer);
Exemplo n.º 15
0
 public abstract void ValueToJson(JsonWriter writer, Row row, JsonSerializer serializer);
Exemplo n.º 16
0
        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();
            }
        }
Exemplo n.º 17
0
 public static string GetConnectionKey(Row row)
 {
     return GetConnectionKey(row.GetType());
 }
Exemplo n.º 18
0
 protected abstract bool GetIsNull(Row row);
Exemplo n.º 19
0
 public bool IsNull(Row row)
 {
     CheckUnassignedRead(row);
     return GetIsNull(row);
 }
Exemplo n.º 20
0
 public void CopyNoAssignment(Row source, Row target)
 {
     Copy(source, target);
     target.ClearAssignment(this);
 }