Exemple #1
0
        //Scoped模式
        public BaseService(IContext context)
        {
            this.context    = context;
            this.repository = Repository <T> .Instance;
            this.collection = repository.GetCollection();

            if (this.GetContext() != null && this.GetContext().IsUseCache)
            {
                cache = LocalCache <T> .Instance;
                RebuildCache();
            }
        }
Exemple #2
0
        //Singleton模式
        public BaseService(IContextRepository contextRepository)
        {
            this.contextRepository = contextRepository;
            this.repository        = Repository <T> .Instance;
            this.collection        = repository.GetCollection();

            //if (this.GetContext() != null && this.GetContext().IsUseCache)
            //{
            //    cache = LocalCache<T>.Instance;
            //    RebuildCache();
            //}

            cache = LocalCache <T> .Instance;
            RebuildCache();
        }