<commit_before>﻿//******************************************
//  Copyright (C) 2014-2015 <NAME>  *
//                                         *
//  Licensed under MIT License             *
//  (see included LICENSE)                 *
//                                         *
// *****************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Naif.Core.Caching;
using Naif.Core.Collections;
using Naif.Core.Contracts;
using Naif.Data.ComponentModel;

namespace Naif.Data
{
    public abstract class RepositoryBase<TModel> : IRepository<TModel> where TModel : class
    {
        private ICacheProvider _cache;

        protected RepositoryBase(ICacheProvider cache)
        {
            Requires.NotNull("cache", cache);

            _cache = cache;

            Initialize();

        }

        protected string CacheKey { get; private set; }

        protected bool IsCacheable { get; private set; }

        protected bool IsScoped { get; private set; }

        protected string Scope { get; private set; }

        public void Add(TModel item)
        {
            AddInternal(item);
            ClearCache(item);
        }

        public void Delete(TModel item)
        {
            DeleteInternal(item);
            ClearCache(item);
        }

        public abstract IEnumerable<TModel> Find(string sqlCondition, params object[] args);

        public abstract IPagedList<TModel> Find(int pageIndex, int pageSize, string sqlCondition, params object[] args);

        public abstract IEnumerable<TModel> Find(Expression<Func<TModel, bool>> predicate);

        public abstract IPagedList<TModel> Find(int pageIndex, int pageSize, Expression<Func<TModel, bool>> predicate);

        public IEnumerable<TModel> Get<TScopeType>(TScopeType scopeValue)
        {
            CheckIfScoped();

            return IsCacheable
                ? _cache.GetCachedObject(String.Format(CacheKey, scopeValue), () => GetByScopeInternal(scopeValue))
                : GetByScopeInternal(scopeValue);
        }

        public IEnumerable<TModel> GetAll()<commit_msg>Make properties of Repository public<commit_after>﻿//******************************************
//  Copyright (C) 2014-2015 <NAME>  *
//                                         *
//  Licensed under MIT License             *
//  (see included LICENSE)                 *
//                                         *
// *****************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Naif.Core.Caching;
using Naif.Core.Collections;
using Naif.Core.Contracts;
using Naif.Data.ComponentModel;

namespace Naif.Data
{
    public abstract class RepositoryBase<TModel> : IRepository<TModel> where TModel : class
    {
        private readonly ICacheProvider _cache;

        protected RepositoryBase(ICacheProvider cache)
        {
            Requires.NotNull("cache", cache);

            _cache = cache;

            Initialize();
        }

        public string CacheKey { get; set; }

        public bool IsCacheable { get; set; }

        public bool IsScoped { get; set; }

        public string Scope { get; set; }

        public void Add(TModel item)
        {
            AddInternal(item);
            ClearCache(item);
        }

        public void Delete(TModel item)
        {
            DeleteInternal(item);
            ClearCache(item);
        }

        public abstract IEnumerable<TModel> Find(string sqlCondition, params object[] args);

        public abstract IPagedList<TModel> Find(int pageIndex, int pageSize, string sqlCondition, params object[] args);

        public abstract IEnumerable<TModel> Find(Expression<Func<TModel, bool>> predicate);

        public abstract IPagedList<TModel> Find(int pageIndex, int pageSize, Expression<Func<TModel, bool>> predicate);

        public IEnumerable<TModel> Get<TScopeType>(TScopeType scopeValue)
        {
            CheckIfScoped();

            return IsCacheable
                ? _cache.GetCachedObject(String.Format(CacheKey, scopeValue), () => GetByScopeInternal(scopeValue))
                : GetByScopeInternal(scopeValue);
        }

        public IEnumerable<TModel> GetAll()
{'fraction_non_alphanumeric': 0.1253745102558193, 'fraction_numerical': 0.0036874855957593914, 'mean_word_length': 2.2804232804232805, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2863463', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1072, 'n_words': 274}