using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StackExchange.Redis;

namespace OASystem.RedisRepository.CommonHelper
{
    internal class RedisInnerTypeHelper
    {
        public static List<T> RedisValuesToGenericList<T>(RedisValue[] redisValues)
        {
            var result=new List<T>();
            redisValues.ToList().ForEach(r => result.Add(SerializeHelper.Deserialize<T>(r)));
            return result;
        }
        public static RedisValue[] GenericListToRedisValues<T>(List<T> values)
        {
            var redisValues = new List<RedisValue>();
            values.ForEach(v => redisValues.Add(SerializeHelper.Serialize(values)));
            return redisValues.ToArray();
        }

        public static RedisKey[] GenericListToRedisKeys(List<string> keys)
        {
            var redisKeys = new List<RedisKey>();
            keys.ForEach(k => redisKeys.Add(k));
            return redisKeys.ToArray();
        }
    }
}
