Esempio n. 1
0
        object ReadList(Type listType, string tablePath, Type itemType, ExcelToObjectAttribute attr)
        {
            object listObj = Util.New(listType);

            var context = new ExcelReader.ReadContext();

            bool retn = mReader.ReadListInternal(tablePath, itemType, context, listObj as IList);

            return(retn ? listObj : null);
        }
Esempio n. 2
0
        object ReadSingle(Type itemType, string tablePath, ExcelToObjectAttribute attr)
        {
            List <object> listObj = new List <object>();

            var context = new ExcelReader.ReadContext()
            {
                readMaxRows = 1
            };

            bool retn = mReader.ReadListInternal(tablePath, itemType, context, listObj);

            return(retn ? listObj[0] : null);
        }
Esempio n. 3
0
        object ReadDictionary(Type dicType, string tablePath, Type valueType, ExcelToObjectAttribute attr)
        {
            object dicObj = Util.New(dicType);

            var context = new ExcelReader.ReadContext();

            ExcelReader.KeySelector keySelector = null;
            if (attr != null && attr.DictionaryKeyName.IsValid())
            {
                keySelector = ExcelReader.KeySelector.From(valueType, attr.DictionaryKeyName);
            }

            bool retn = mReader.ReadDictionaryInternal(tablePath, valueType, context, dicObj as IDictionary, keySelector);

            return(retn ? dicObj : null);
        }