Beispiel #1
0
        public void OnReadValue(int key, IValueWriter valueWriter)
        {
            DataRowRW <DataRow> reader;

            if (valueWriter is IUsePool)
            {
                reader = DataRowRW;
            }
            else
            {
                reader = new DataRowRW <DataRow>();
            }


            reader.Initialize(Content.Rows[key]);

            if (key != 0 && (Options & DataTableRWOptions.WriteToArrayFromBeginningSecondRows) != 0)
            {
                valueWriter.WriteArray(reader);
            }
            else
            {
                valueWriter.WriteObject(reader);
            }
        }
        public T ReadValue(IValueReader valueReader)
        {
            if (valueReader is IValueReader <T> tReader)
            {
                return(tReader.ReadValue());
            }

            var dataWriter = new DataRowRW <T>();

            valueReader.ReadObject(dataWriter);

            return(dataWriter.Content);
        }
Beispiel #3
0
        public void OnWriteValue(int key, IValueReader valueReader)
        {
            if (DataTable == null && Initialized && key == 0)
            {
                DataRowRW.Clear();

                valueReader.ReadObject(DataRowRW);

                Fill();

                return;
            }

            DataRowRW <DataRow> writer;

            if (valueReader is IUsePool)
            {
                writer = DataRowRW;
            }
            else
            {
                writer = new DataRowRW <DataRow>();
            }

            writer.Clear();

            if (key == DataTable.Rows.Count)
            {
                writer.Initialize(DataTable.NewRow());

                valueReader.ReadObject(writer);

                DataTable.Rows.Add(writer.Content);
            }
            else
            {
                writer.Initialize(DataTable.Rows[key]);

                valueReader.ReadObject(writer);
            }
        }
        public void WriteValue(IValueWriter valueWriter, T value)
        {
            if (value == null)
            {
                valueWriter.DirectWrite(null);

                return;
            }

            if (valueWriter is IValueWriter <T> tWriter)
            {
                tWriter.WriteValue(value);

                return;
            }

            var dataReader = new DataRowRW <T>();

            dataReader.Initialize(value);

            valueWriter.WriteObject(dataReader);
        }
        public void WriteValue(IValueWriter valueWriter, T value)
        {
            if (value is null)
            {
                valueWriter.DirectWrite(null);

                return;
            }

            if (valueWriter is IValueWriter <T> tWriter)
            {
                tWriter.WriteValue(value);

                return;
            }

            var dataReader = new DataRowRW <T>
            {
                datarow = value
            };

            valueWriter.WriteObject(dataReader);
        }
Beispiel #6
0
        public DataTableRW(DataTableRWOptions options)
        {
            DataRowRW = new DataRowRW <DataRow>((options & DataTableRWOptions.SetFirstRowsTypeToColumnTypes) != 0);

            Options = options;
        }