Ejemplo n.º 1
0
        internal bool ReadDictionaryInternal(Type valueType, IDictionary destDic, KeySelector keySelector = null)
        {
            List <object> values = new List <object>();

            bool retn = ReadListInternal(valueType, 0, values);

            if (retn == false)
            {
                return(false);
            }

            if (keySelector == null)
            {
                keySelector = KeySelector.From(valueType, GetColumnName(0));
            }

            foreach (object value in values)
            {
                object key = keySelector.Select(value);

                try
                {
                    destDic.Add(key, value);
                }
                catch (ArgumentException ae)
                {
                    // Key already exists?
                    throw new Exception(string.Format("Duplicated key : tablePath={0}, key={1}", mName, key), ae);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        internal bool ReadDictionaryInternal(string tablePath, Type valueType, ReadContext context, IDictionary destDic, KeySelector keySelector = null)
        {
            List <object> values = new List <object>();

            bool retn = ReadListInternal(tablePath, valueType, context, values);

            if (retn == false)
            {
                return(false);
            }

            if (keySelector == null)
            {
                keySelector = KeySelector.From(valueType, context.table.GetColumnName(0));
            }

            foreach (object value in values)
            {
                object key = keySelector.Select(value);

                destDic.Add(key, value);
            }

            return(true);
        }