Parse() public static method

从字符串中解析出缓存优先级信息
public static Parse ( string str ) : CachePriority
str string 要解析的字符串
return CachePriority
Example #1
0
        /// <summary>
        /// 从字符串中解析出缓存策略对象
        /// </summary>
        /// <param name="str">要解析的字符串</param>
        /// <returns>缓存策略对象</returns>
        public static CachePolicyItem Parse(string str)
        {
            if (str == null)
            {
                throw new ArgumentNullException(str);
            }

            var data = str.Split(',');

            if (data.Length != 2)
            {
                throw new FormatException();
            }

            var expires  = long.Parse(data[0]);
            var prioroty = CachePriority.Parse(data[1]);


            return(new CachePolicyItem(new DateTime(expires, DateTimeKind.Utc), null, prioroty));
        }