Пример #1
0
        /// <summary>
        /// 開啟資料庫
        /// </summary>
        /// <param name="jsons">json字串列表</param>
        /// <returns>資料庫物件</returns>
        public RepositoryJson <T> open(IEnumerable <string> jsons)
        {
            close();

            if (jsonAdaper == null)
            {
                throw new Exception("json adaper null");
            }

            foreach (string itor in jsons)
            {
                T data = jsonAdaper.toObject(itor) as T;

                if (data == null)
                {
                    throw new Exception("parse data failed");
                }

                object key = data.getKey();

                if (key == null)
                {
                    throw new Exception("parse key failed");
                }

                datas.Add(key, data);
            }//for

            return(this);
        }