示例#1
0
        /// <summary>
        /// 创建一个储存库
        /// </summary>
        /// <param name="conn">连接的数据库</param>
        public Storage(SQLiteConnection conn) : base(conn)
        {
            _transaction = conn.BeginTransaction();

            _filtersLocker           = new object();
            _containersLocker        = new object();
            _contianerTemplateLocker = new object();

            _filters           = new FilterCollection();
            _containers        = new ContainerCollection();
            _containerTemplate = new ContainerTemplate(conn);
        }
示例#2
0
        /// <summary>
        /// 将Container内容复制到Contaienr模板
        /// </summary>
        /// <param name="container">要复制内容的Container</param>
        /// <returns></returns>
        public async Task SetContainerToTemplateAsync(IContainer container)
        {
            Container c = container as Container;
            await ContainerTemplate.SetAvatarAsync(container.Avatar);

            ContainerTemplate.Header      = c.Header;
            ContainerTemplate.Description = c.Description;
            ContainerTemplate.Filter      = c.Filter;
            ContainerTemplate.FilterUID   = c.FilterUID;
            ContainerTemplate.Pairs.Clear();
            foreach (IPair pairSource in c.FetchPairs((p) => true))
            {
                IPair pair = await ContainerTemplate.AddPairAsync();

                pair.Title  = pairSource.Title;
                pair.Detail = pairSource.Detail;
            }
        }