Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenDbRepository&lt;T, TKey&gt;"/> class.
 /// </summary>
 /// <param name="url">The URL of the RavenDb instance.</param>
 /// <param name="cachingStrategy">The caching strategy.  Defaults to <see cref="NoCachingStrategy&lt;T, TKey&gt;" />.</param>
 public RavenDbRepository(string url, ICachingStrategy <T, TKey> cachingStrategy = null) : base(url, cachingStrategy)
 {
     if (String.IsNullOrEmpty(url))
     {
         throw new ArgumentNullException("url");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenDbRepository&lt;T, TKey&gt;"/> class.
 /// </summary>
 /// <param name="documentStore">The instantiated RavenDb Document Store.</param>
 /// <param name="cachingStrategy">The caching strategy.  Defaults to <see cref="NoCachingStrategy&lt;T, TKey&gt;" />.</param>
 public RavenDbRepository(DocumentStore documentStore, ICachingStrategy <T, TKey> cachingStrategy = null) : base(documentStore, cachingStrategy)
 {
     if (documentStore == null)
     {
         throw new ArgumentNullException("documentStore");
     }
 }
Exemplo n.º 3
0
 /// <inheritdoc />
 public CachingCallsWrapper(ICachingStrategy cachingStrategy)
 {
     _cachingStrategy = cachingStrategy;
     _retryPolicy     = Policy
                        .CacheAsync(new MemoryCacheProvider(new MemoryCache(new MemoryCacheOptions())),
                                    new ContextualTtl());
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XmlRepository&lt;T, TKey&gt;"/> class.
 /// </summary>
 /// <param name="storagePath">Path to the directory where the XML files are stored.  The XML filename is determined by the TypeName</param>
 /// <param name="cachingStrategy">The caching strategy.  Defaults to <see cref="NoCachingStrategy&lt;T, TKey&gt;" />.</param>
 public XmlRepository(string storagePath, ICachingStrategy <T, TKey> cachingStrategy = null) : base(storagePath, cachingStrategy)
 {
     if (String.IsNullOrEmpty(storagePath))
     {
         throw new ArgumentNullException("storagePath");
     }
 }
 internal RavenDbRepositoryBase(IDocumentSession session,
                                ICachingStrategy <TEntity, TKey> cachingStrategy = null)
     : base(cachingStrategy)
 {
     Session = session ?? throw new ArgumentNullException("dbContext");
     /*  Initialize();*/
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonRepository&lt;T, TKey&gt;"/> class.
 /// </summary>
 /// <param name="storagePath">Path to the directory where the XML files are stored.  The XML filename is determined by the TypeName</param>
 /// <param name="cachingStrategy">The caching strategy.  Defaults to <see cref="NoCachingStrategy&lt;T, TKey&gt;" />.</param>
 public JsonRepository(string storagePath, ICachingStrategy <T, TKey>?cachingStrategy = null) : base(storagePath, cachingStrategy)
 {
     if (string.IsNullOrEmpty(storagePath))
     {
         throw new ArgumentNullException(nameof(storagePath));
     }
 }
Exemplo n.º 7
0
 public void Setup()
 {
     _stubStrategy = MockRepository.GenerateStub<ICachingStrategy>();
     _stubEncoder = MockRepository.GenerateStub<ICacheItemEncoder>();
     _c = new Cache(_stubStrategy, _stubEncoder);
     _oneHour = new TimeSpan(1,0,0);
 }
Exemplo n.º 8
0
 internal EfRepositoryBase(DbContext dbContext, ICachingStrategy <T, TKey> cachingStrategy = null) : base(cachingStrategy)
 {
     if (dbContext == null)
     {
         throw new ArgumentNullException("dbContext");
     }
     Initialize(dbContext);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoDbRepository&lt;T, TKey&gt;"/> class.
 /// </summary>
 /// <param name="connectionString">The connectionString of the MongoDb instance.</param>
 /// <param name="cachingStrategy">The caching strategy.  Defaults to <see cref="NoCachingStrategy&lt;T, TKey&gt;" />.</param>
 public MongoDbRepository(string connectionString, ICachingStrategy <T, TKey> cachingStrategy = null)
     : base(connectionString, cachingStrategy)
 {
     if (String.IsNullOrEmpty(connectionString))
     {
         throw new ArgumentNullException("connectionString");
     }
 }
 internal EfCoreRepositoryBase(
     ICoreDbContext contextFactory,
     ICachingStrategy <T, TKey> cachingStrategy = null)
     : base(cachingStrategy)
 {
     this.context = contextFactory;
     DbSet        = context.Set <T>();
 }
Exemplo n.º 11
0
        internal MongoDbRepositoryBase(string connectionString, ICachingStrategy <T, TKey> cachingStrategy = null)
            : base(cachingStrategy)
        {
            _databaseName = MongoUrl.Create(connectionString).DatabaseName;
            var cli = new MongoClient(connectionString);

            Initialize(cli.GetDatabase(_databaseName));
        }
Exemplo n.º 12
0
 public DBFTable( string filename, bool readOnly, ICachingStrategy strategy )
 {
     _filename = filename;
     _stream = new CachedStream(
         ( readOnly ) ? IOTools.OpenRead( filename ) : IOTools.Open( filename ), strategy );
     _recordArray = null;
     CreateBinaryReader();
     LoadStructure();
 }
Exemplo n.º 13
0
 /// <inheritdoc />
 public CachingCallsWrapper(ICachingStrategy cachingStrategy, IRemovableAsyncCacheProvider asyncCacheProvider)
 {
     _cacheKeys          = new ConcurrentDictionary <string, object>();
     _asyncCacheProvider = asyncCacheProvider;
     _cachingStrategy    = cachingStrategy;
     _retryPolicy        = Policy
                           .CacheAsync(_asyncCacheProvider,
                                       new ContextualTtl());
 }
Exemplo n.º 14
0
        public ICacheStorageFactory WithSlidingExpiration(uint durationInSeconds)
        {
            var dateTimeProvider = GetService <ITimeProvider>(_configurator.ServiceProvider);
            var logger           = GetService <ILogger <SlidingExpirationCachingStrategy> >(_configurator.ServiceProvider);

            _strategy = new SlidingExpirationCachingStrategy(dateTimeProvider,
                                                             new CacheStrategyOptions(TimeSpan.FromSeconds(durationInSeconds)), logger);
            return(this);
        }
        public void Setup()
        {
            // need to clear out the InMemory cache before each test is run so that each is independent and won't effect the next one
            var provider = new InMemoryCachingProvider(new MemoryCache(new MemoryCacheOptions()));

            CachingStrategy = new StandardCachingStrategy <Contact, int>(provider)
            {
                CachePrefix = "#RepoStandardCache"
            };
        }
        public void Setup()
        {
            Cache = new MemoryCache(new MemoryCacheOptions());
            var cacheProvider = new InMemoryCachingProvider(Cache);

            CachingStrategy = new StandardCachingStrategyWithPartition <Contact, int, int>(cacheProvider, c => c.ContactTypeId)
            {
                CachePrefix = "#RepoStandardCacheWithPartition"
            };
        }
Exemplo n.º 17
0
 public CachedStream(Stream stream, ICachingStrategy strategy)
 {
     if (!stream.CanSeek)
     {
         throw new ArgumentException(
                   "Underlying stream should be a random-access one (stream.CanSeek is true).", "stream");
     }
     _stream          = stream;
     _length          = _stream.Length;
     _position        = _stream.Position;
     _isOpen          = true;
     _cachingStrategy = strategy;
 }
Exemplo n.º 18
0
        public void Setup()
        {
            // need to clear out the InMemory cache before each test is run so that each is independent and won't effect the next one
            var cache = MemoryCache.Default;

            foreach (var item in cache)
            {
                cache.Remove(item.Key);
            }

            CachingStrategy = new StandardCachingStrategy <Contact, int>()
            {
                CachePrefix = "#RepoStandardCache"
            };
        }
Exemplo n.º 19
0
        protected RepositoryBase(ICachingStrategy <T, TKey> cachingStrategy = null)
        {
            if (typeof(T) == typeof(TKey))
            {
                // this check is mainly because of the overloaded Delete methods Delete(T) and Delete(TKey), ambiguous reference if the generics are the same
                throw new InvalidOperationException("The repository type and the primary key type can not be the same.");
            }

            Conventions     = new RepositoryConventions();
            CachingStrategy = cachingStrategy ?? new NoCachingStrategy <T, TKey>(); // sets QueryManager as well
            // the CachePrefix is set to the default convention in the CachingStrategyBase class, the user to override when passing in an already created CachingStrategy class

            _entityType = typeof(T);
            _typeName   = _entityType.Name;
        }
        internal AzureBlobRepositoryBase(string connectionString, string containerName, bool createIfNotExists,
                                         ICachingStrategy <T, TKey> cachingStrategy = null)
            : base(cachingStrategy)
        {
            var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);

            ContainerName = TypeName.ToLower();

            if (!String.IsNullOrEmpty(containerName))
            {
                ContainerName = containerName;
            }

            CreateIfNotExists = createIfNotExists;
            BlobClient        = storageAccount.CreateCloudBlobClient();
            SetContainer();
        }
Exemplo n.º 21
0
        public CosmosDbRepository(string endpointUrl,
                                  string authorizationKey,
                                  string databaseId,
                                  bool createIfNotExists,
                                  string collectionId = null,
                                  ICachingStrategy <T, string> cachingStrategy = null) :
            base(endpointUrl, authorizationKey, databaseId, createIfNotExists, collectionId, cachingStrategy)
        {
            base.Client.Dispose();

            var client = new DocumentClient(new Uri(endpointUrl), authorizationKey,
                                            new JsonSerializerSettings
            {
                Converters        = JsonConverterProviders.Converters.ToList(),
                NullValueHandling = NullValueHandling.Ignore
            });

            base.Client = client;
        }
        internal MongoDbRepositoryBase(string connectionString, ICachingStrategy <T, TKey> cachingStrategy, SslSettings sslSettings)
            : base(cachingStrategy)
        {
            _databaseName = MongoUrl.Create(connectionString).DatabaseName;

            MongoClient cli;

            if (sslSettings != null)
            {
                var settings = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
                settings.SslSettings = sslSettings;
                cli = new MongoClient(settings);
            }
            else
            {
                cli = new MongoClient(connectionString);
            }

            Initialize(cli.GetDatabase(_databaseName));
        }
Exemplo n.º 23
0
 protected LinqRepositoryBase(ICachingStrategy <T, TKey> cachingStrategy = null) : base(cachingStrategy)
 {
 }
Exemplo n.º 24
0
 public CompanyRepository(DbContext dbContext, ICachingStrategy <Company, int> cachingStrategy = null)
     : base(dbContext, cachingStrategy)
 {
 }
Exemplo n.º 25
0
 public SaleLineItemRepository(DbContext dbContext, ICachingStrategy <SaleLineItem, int> cachingStrategy = null)
     : base(dbContext, cachingStrategy)
 {
 }
Exemplo n.º 26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="storagePath">Path to the directory.  The XML filename is determined by the TypeName</param>
 /// <param name="cachingStrategy"></param>
 internal XmlRepositoryBase(string storagePath, ICachingStrategy <T, TKey> cachingStrategy = null) : base(cachingStrategy)
 {
     Initialize(storagePath);
 }
Exemplo n.º 27
0
 public TaskDevelopmentRepository(DbContext dbContext, ICachingStrategy <Task_Development, int> cachingStrategy = null)
     : base(dbContext, cachingStrategy)
 {
 }
Exemplo n.º 28
0
 internal InMemoryRepositoryBase(ICachingStrategy <T, TKey> cachingStrategy = null) : base(cachingStrategy)
 {
 }
Exemplo n.º 29
0
 public AssemblyResolver(ICachingStrategy<string, AssemblyDefinition> assemblyCache)
 {
     _assemblyCachingStrategy = assemblyCache;
 }
        public void Setup()
        {
            // need to clear out the InMemory cache before each test is run so that each is independent and won't effect the next one
            var cache = MemoryCache.Default;
            foreach (var item in cache)
            {
                cache.Remove(item.Key);
            }

            CachingStrategy = new StandardCachingStrategyWithPartition<Contact, int, int>(c => c.ContactTypeId) { CachePrefix = "#RepoStandardCacheWithPartition" };
        }
Exemplo n.º 31
0
 /// <summary>
 /// Configures the caching strategy to use. If not called - the default one is used.
 /// </summary>
 public HttpClientGeneratorBuilder WithCachingStrategy([NotNull] ICachingStrategy cachingStrategy)
 {
     _cachingStrategy = cachingStrategy ?? throw new ArgumentNullException(nameof(cachingStrategy));
     return(this);
 }
Exemplo n.º 32
0
 /// <summary>
 /// Configures not to use methods results caching
 /// </summary>
 public HttpClientGeneratorBuilder WithoutCaching()
 {
     _cachingStrategy = null;
     return(this);
 }
Exemplo n.º 33
0
 public SiteRepository(DbContext dbContext, ICachingStrategy <Site, int> cachingStrategy = null)
     : base(dbContext, cachingStrategy)
 {
 }