예제 #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();
        }
예제 #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;
 }
예제 #4
0
파일: Row.cs 프로젝트: VictorTomaili/Sanity
        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;
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #7
0
 public RowValidationContext(IDbConnection connection, Row row)
 {
     this.row = row;
     this.Connection = connection;
 }
예제 #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));
        }
예제 #9
0
 public abstract void AsObject(Row row, object value);
예제 #10
0
 public abstract object AsObject(Row row);
예제 #11
0
 public abstract int IndexCompare(Row row1, Row row2);
예제 #12
0
 public abstract void GetFromReader(IDataReader reader, int index, Row row);
예제 #13
0
 public abstract void Copy(Row source, Row target);
예제 #14
0
 public abstract void ValueFromJson(JsonReader reader, Row row, JsonSerializer serializer);
예제 #15
0
 public abstract void ValueToJson(JsonWriter writer, Row row, JsonSerializer serializer);
예제 #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();
            }
        }
예제 #17
0
 public static string GetConnectionKey(Row row)
 {
     return GetConnectionKey(row.GetType());
 }
예제 #18
0
 protected abstract bool GetIsNull(Row row);
예제 #19
0
 public bool IsNull(Row row)
 {
     CheckUnassignedRead(row);
     return GetIsNull(row);
 }
예제 #20
0
 public void CopyNoAssignment(Row source, Row target)
 {
     Copy(source, target);
     target.ClearAssignment(this);
 }