<commit_before>using System;
using System.Data;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;

namespace Serenity.Data
{
    public sealed class DoubleField : GenericValueField<Double>
    {
        public DoubleField(ICollection<Field> collection, string name, LocalText caption = null, int size = 0, FieldFlags flags = FieldFlags.Default, 
            Func<Row, Double?> getValue = null, Action<Row, Double?> setValue = null)
            : base(collection, FieldType.Double, name, caption, size, flags, getValue, setValue)
        {
        }

        public static DoubleField Factory(ICollection<Field> collection, string name, LocalText caption, int size, FieldFlags flags,
            Func<Row, Double?> getValue, Action<Row, Double?> setValue)
        {
            return new DoubleField(collection, name, caption, size, flags, getValue, setValue);
        }

        public override void GetFromReader(IDataReader reader, int index, Row row)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (reader.IsDBNull(index))
                _setValue(row, null);
            else
                _setValue(row, Convert.ToDouble(index, CultureInfo.InvariantCulture));

            if (row.tracking)
                row.FieldAssignedValue(this);
        }

        public override void ValueToJson(JsonWriter writer, Row row, JsonSerializer serializer)
        {
            writer.WriteValue(_getValue(row));
        }

        public override void ValueFromJson(JsonReader reader, Row row, JsonSerializer serializer)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            switch (reader.TokenType)
            {
                case JsonToken.Null:
                case JsonToken.Undefined:
                    _setValue(row, null);
                    break;
                case JsonToken.Integer:<commit_msg>Revert "getdouble todouble e çevrildi"<commit_after>using System;
using System.Data;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;

namespace Serenity.Data
{
    public sealed class DoubleField : GenericValueField<Double>
    {
        public DoubleField(ICollection<Field> collection, string name, LocalText caption = null, int size = 0, FieldFlags flags = FieldFlags.Default, 
            Func<Row, Double?> getValue = null, Action<Row, Double?> setValue = null)
            : base(collection, FieldType.Double, name, caption, size, flags, getValue, setValue)
        {
        }

        public static DoubleField Factory(ICollection<Field> collection, string name, LocalText caption, int size, FieldFlags flags,
            Func<Row, Double?> getValue, Action<Row, Double?> setValue)
        {
            return new DoubleField(collection, name, caption, size, flags, getValue, setValue);
        }

        public override void GetFromReader(IDataReader reader, int index, Row row)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (reader.IsDBNull(index))
                _setValue(row, null);
            else
                _setValue(row, reader.GetDouble(index));

            if (row.tracking)
                row.FieldAssignedValue(this);
        }

        public override void ValueToJson(JsonWriter writer, Row row, JsonSerializer serializer)
        {
            writer.WriteValue(_getValue(row));
        }

        public override void ValueFromJson(JsonReader reader, Row row, JsonSerializer serializer)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            switch (reader.TokenType)
            {
                case JsonToken.Null:
                case JsonToken.Undefined:
                    _setValue(row, null);
                    break;
                case JsonToken.Integer:
{'fraction_non_alphanumeric': 0.08407191694099772, 'fraction_numerical': 0.0005064573309698658, 'mean_word_length': 2.1983805668016196, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7140114', 'n_tokens_mistral': 1009, 'n_tokens_neox': 965, 'n_words': 276}