示例#1
0
        public IGrouping <TToKey, TToElement> Map(IGrouping <TFromKey, TFromElement> from, IObjectMapperResolver resolver)
        {
            if (from == null)
            {
                return(null);
            }

            var keyMapper     = resolver.GetMapperWithVerify <TFromKey, TToKey>();
            var elementMapper = resolver.GetMapperWithVerify <TFromElement, TToElement>();

            var key    = keyMapper.Map(from.Key, resolver);
            var values = new ArrayBuffer <TToElement>(from.FastCount() ?? 4);

            foreach (var item in from)
            {
                values.Add(elementMapper.Map(item, resolver));
            }

            return(new Grouping <TToKey, TToElement>(key, values.ToArray()));
        }