Esempio n. 1
0
        public static IDataReader CreateReader <T>(T obj, bool throwException = true)
        {
            var auxiliary = new AuxiliaryValueRW();

            ValueInterface <T> .WriteValue(auxiliary, obj);

            return(auxiliary.GetDataReader() ?? (throwException ? throw new NotSupportedException($"Unable create data reader of '{typeof(T)}'.") : default(IDataReader)));
        }
Esempio n. 2
0
        public static IDataReader CreateItemReader <TKey>(IDataReader <TKey> dataReader, TKey key, bool throwException = true)
        {
            var auxiliary = new AuxiliaryValueRW();

            dataReader.OnReadValue(key, auxiliary);

            return(auxiliary.GetDataReader() ??
                   (throwException ? throw new NotSupportedException($"Failed to create data reader of field : '{key}' in {dataReader}.") : default(IDataReader)));
        }
Esempio n. 3
0
        public static IDataReader CreateReader(object obj, bool throwException = true)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var auxiliary = new AuxiliaryValueRW();

            ValueInterface.GetInterface(obj).Write(auxiliary, obj);

            return(auxiliary.GetDataReader() ?? (throwException ? throw new NotSupportedException($"Unable create data reader of '{obj.GetType()}'.") : default(IDataReader)));
        }
Esempio n. 4
0
        public static IDataReader CreateItemReader <TKey>(IDataReader <TKey> dataReader, TKey key, bool throwException = true)
        {
            var auxiliary = new AuxiliaryValueRW();

            if (typeof(TKey) == typeof(long) && ((dataReader as IAsDataReader)?.Content ?? dataReader) is IId64DataRW id64DataRW)
            {
                id64DataRW.OnReadValue(Unsafe.As <TKey, long>(ref key), auxiliary);
            }
            else
            {
                dataReader.OnReadValue(key, auxiliary);
            }

            return(auxiliary.GetDataReader() ?? (throwException ? throw new NotSupportedException($"Failed to create data reader of field : '{key}' in {dataReader}.") : default(IDataReader)));
        }